Php parsing xml format ----- urgent !!!!!!!!!!!!!! & Lt; timezone & gt; & lt; id & gt; hell & lt; id & gt; & lt; raw_offset & gt; 2 & lt; raw_offset & gt; & lt; dst & gt; & lt; start_month & gt; 02 & lt; start_month & gt; & lt; start php parses xml format ----- urgent !!!!!!!!!!!!!!
hell
2
02
29
00
02
00
09
06
00
02
00
I want to get start_month, start_day... and so on .. Thank you for your help ..
------ Solution --------------------
Private function writeOrgin (){
// Output the array to the XML file
// By MoreWindows (http://blog.csdn.net/MoreWindows)
$ Article_array = array (
"Article 1" => array (
"Title" => "accessing MySql database using PHP ",
"Link" => "http://blog.csdn.net/morewindows/article/details/7102362"
),
"Article 2" => array (
"Title" => "accessing MySql database using PHP intermediate Smarty technology ",
"Link" => "http://blog.csdn.net/morewindows/article/details/7094642"
),
"Article 3" => array (
"Title" => "PHP advanced AJAX technology for MySql database access ",
"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 file size'. $ dom-> save ($ filename). 'Byte ';
}*/
// Do not use
/*
Private function readOrgin (){
$ Filename = "D: \ test. xml ";
$ Article_array = array ();
$ Dom = new DOMDocument ('1. 0', 'utf-8 ');
$ Dom-> load ($ filename );
// Obtain the node
$ Articles = $ dom-> getElementsByTagName ("article ");
Echo 'number of knot'. $ 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 );
}
// Output result
Echo"";
var_dump($article_array);
echo "
";
}
Refer to this. I copied it from other places, and I should be able to change it myself.
------ Solution --------------------
$ 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;