php 解析 xml 格式-----急!!!!!!!!!!!!!!
hell
2
02
29
00
02
00
09
06
00
02
00
我要取到start_month,start_day...等等这些数值怎么取。。谢谢各位达人帮忙解答。。
------解决方案-------------------- private function writeOrgin(){
//将数组
输出到XML文件中
// by MoreWindows( http://blog.csdn.net/MoreWindows )
$article_array = array(
"第一篇" => array(
"title"=>"PHP访问MySql数据库 初级篇",
"link"=>"http://blog.csdn.net/morewindows/article/details/7102362"
),
"第二篇" => array(
"title"=>"PHP访问MySql数据库 中级篇 Smarty技术",
"link"=>"http://blog.csdn.net/morewindows/article/details/7094642"
),
"第三篇" => array(
"title"=>"PHP访问MySql数据库 高级篇 AJAX技术",
"link"=>"http://blog.csdn.net/morewindows/article/details/7086524"
),
);
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$rootelement = $dom->createElement("MoreWindows");
foreach ($article_array as $key=>$value)
{
$article = $dom->createElement("article", $key);
$title = $dom->createElement("title", $value['title']);
$link = $dom->createElement("link", $value['link']);
$article->appendChild($title);
$article->appendChild($link);
$rootelement->appendChild($article);
}
$dom->appendChild($rootelement);
$filename = "D:\\test.xml";
echo 'XML文件大小' . $dom->save($filename) . '字节';
}*/
// 不使用
/*
private function readOrgin(){
$filename = "D:\\test.xml";
$article_array = array();
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->load($filename);
//得到结点
$articles = $dom->getElementsByTagName("article");
echo ' 结点个数 ' . $articles->length;
foreach ($articles as $article)
{
$id = $article->getElementsByTagName("id")->item(0)->nodeValue;
$title = $article->getElementsByTagName("title")->item(0)->nodeValue;
$link = $article->getElementsByTagName("link")->item(0)->nodeValue;
$article_array[$id] = array('title'=>$title, 'link'=>$link);
}
//输出结果
echo "
";
var_dump($article_array);
echo "
";
}
参考下这个,当初从别的地方抄来,自己改改应该就能用了
------解决方案--------------------$doc_upp = new DOMDocument();
$doc_upp->load( 'xml.xml' );
$item_note = $doc_upp->getElementsByTagName("dst");
foreach($item_note as $val){
$start_month = $val->getElementsByTagName("start_month")->item(0)->nodeValue;