Php parses xml format-how to handle it

Source: Internet
Author: User
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.