Php parses xml strings. I have such a string $ xmlStr = & quot; & lt ;? Xmlversion = '1. 0' encoding = 'utf-8 '? & Gt; & lt; ExportData & gt; & lt; Body & gt; & lt; Content & gt; & lt; Id & gt; 1 & lt;/Id & gt; & lt; Name & gt; php parses xml strings
I have such a string
$ XmlStr =" 1 Test01 40 2 Test02
80 ";
Want to get the following content
Id = 1
Name = Test01
Point = 40
Id = 2
Name = Test02
Point = 80
How to implement
------ Solution --------------------
PHP code
$ Xml = simplexml_load_string ($ xmlStr); foreach ($ xml-> Body-> Content as $ item) {foreach ($ item as $ k => $ v) echo "$ k $ v \ n ";}
------ Solution --------------------
The related program of the post can be used to avoid the interference of line breaks and other identifiers:
Http://topic.csdn.net/u/20120229/17/2d8adf3f-5273-4330-a399-b67b5e395e3d.html
#17 content and associated content of this post.
Specifically:
1. Compile the array into 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. convert the content of the xml file to the array parse_xml_config ().
You can use it.