PHP Parsing XML strings
I have such a 1 string
$XMLSTR = " 1 Test01 2 Test02
the ";
Want to get the following content
Id = 1
Name = Test01
Point = 40
Id = 2
Name = Test02
Point = 80
How can we achieve
------Solution--------------------
PHP code
$xml =simplexml_load_string ($XMLSTR); foreach ($xml- >body->content as $item) {foreach ($item as $k = + $v) echo "$k $v \ n";}
------Solution--------------------
Use the associated program for this paste, which can be very easy to avoid interference with identifiers such as line breaks:
http://topic.csdn.net/u/20120229/17/ 2d8adf3f-5273-4330-a399-b67b5e395e3d.html
The #17 content and associated content of this post.
Specifically:
1, compile the array as an XML string Dump_xml_config (),
2, write the XML string to the file File_put_contents_safe ();
3, http:// topic.csdn.net/u/20120228/09/cf787cd0-5936-4a15-9661-895f362b5b16.html
#10 to convert the contents of the XML file to an array parse_xml_config ().
Take what you want to use.