PHPXML data parsing code. The code for copying the code is as follows: xmlstring $ xml_string? Xmlversion1.0? UsersusernameFoonameemailfoo@bar.comnameuserusernameFoobarnameemailfoobar @ foo.
The code is as follows:
// Xml string
$ Xml_string ="
Foo
Foo@bar.com
Foobar
Foobar@foo.com
";
// Load the xml string using simplexml
$ Xml = simplexml_load_string ($ xml_string );
// Loop through the each node of user
Foreach ($ xml-> user as $ user)
{
// Access attribute
Echo $ user ['id'], '';
// Subnodes are accessed by-> operator
Echo $ user-> name ,'';
Echo $ user-> email ,'
';
}
This is an excerpt from an article published before the home of scripts. For more tips, refer.
Collected 21 practical and convenient PHP function code
The http://www.bkjia.com/PHPjc/321852.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321852.htmlTechArticle code is as follows: // xml string $ xml_string = "? Xml version = '1. 0 '? Users user id = '20140901' nameFoo/name emailfoo@bar.com/name/user id = '20160901' nameFoobar/name emailfoobar @ foo ....