Php uses simplexml_load_file to load XML files and display XML
This article mainly introduces how php uses simplexml_load_file to load XML files and display XML files. The example analyzes simplexml_load_file's skills for operating XML files, which is very useful. For more information, see
This example describes how php uses simplexml_load_file to load an XML file and display the XML file. Share it with you for your reference. The specific implementation method is as follows:
?
|
1
2
3
4 |
<? Php
$ Xml = simplexml_load_file ("sample. xml ");
Echo htmlspecialchars ($ xml-> asXML ());
?>
|
The content of the sample. xml file is as follows:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 |
<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>
<Book>
<Title> F </title>
<Author gender = "male"> G </author>
<Description> H </description>
</Book>
</Library>
|
I hope this article will help you with php programming.