Php outputs xml attributes, and php outputs xml
This example describes how to output xml attributes in php. Share it with you for your reference. The specific analysis is as follows:
This Code uses a simple example to demonstrate how php reads xml files and outputs xml attributes.
<? Php $ xml = simplexml_load_file ("books. xml "); foreach ($ xml-> book [0]-> author-> attributes () AS $ a => $ B) {echo "$ a = $ B <br/>" ;}?>
The content of the xml file is as follows:
<Library> <book> <title> A </title> <author gender = "female"> B </author> <description> C </description> </book> <book> <title> C </title> <author gender = "male"> D </author> <description> E </description> </book> <title> F </title> <author gender = "male"> G </author> <description> H </description> </book> </library>
I hope this article will help you with php programming.