A large number of SmipleXML functions can be used to load and parse a large number of XML documents.
--------------------------------------------------------------------------------
1.
SimpleXML_load_file ()Function to load the specified XML file to the object. If a problem occurs during file loading, FLASE is returned. Example:
Book. xml file:
Copy codeThe Code is as follows: <? Xml version = "1.0" standalone = "yes"?>
<Library>
<Book>
<Title> Pride and Prejudice </title>
<Author gender = "female"> Jane Austen </author>
<Description> Jane Austen's most popular work. </description>
</Book>
<Book>
<Title> The Conformist </title>
<Author gender = "male"> Albert to Moravia </author>
<Description> Albert to Moravia's classic psyhcological novel. </description>
</Book>
<Book>
<Title> The Sun Also Rises </title>
<Author gender = "male"> Ernest Hemingway </author>
<Description> The masterpiece that launched Hemingway's career. </description>
</Book>
</Library>
PHP file:Copy codeThe Code is as follows: <? Php
$ Xml = simplexml_load_file ("book. xml"); echo "<pre> ";
Var_dump ($ xml );
?>
Output result:Copy codeThe Code is as follows: object (SimpleXMLElement) #1 (1 ){
["Book"] =>
Array (3 ){
[0] =>
Object (SimpleXMLElement) #2 (3 ){
["Title"] =>
String (19) "Pride and Prejudice"
["Author"] =>
String (11) "Jane Austen"
["Description"] =>
String (32) "Jane Austen's most popular work ."
}
[1] =>
Object (SimpleXMLElement) #3 (3 ){
["Title"] =>
String (14) "The Conformist"
["Author"] =>
String (15) "Albert to Moravia"
["Description"] =>
String (46) "Albert to Moravia's classic psyhcological novel ."
}
[2] =>
Object (SimpleXMLElement) #4 (3 ){
["Title"] =>
String (18) "The Sun Also Rises"
["Author"] =>
String (16) "Ernest Hemingway"
["Description"] =>
String (49) "The masterpiece that launched Hemingway's career ."
}
}
}