SimpleXML is an extension for PHP that makes it easy to work with and get XML data.
PHP SimpleXML – Get Node Values
Get the values of the nodes from the file \”example.xml\”:
Here is XML file example
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<note>
<to>Ram</to>
<from>Shyam</from>
<heading>Message</heading>
<body>Lets do tracking this weekend!</body>
</note>
Get Node Values Example
<!DOCTYPE html>
<html>
<body><?php
$file_xml=simplexml_load_file(\”note.xml\”) or die(\”Error: Cannot create object\”);
echo $file_xml->to . \”<br>\”;
echo $file_xml->from . \”<br>\”;
echo $file_xml->heading . \”<br>\”;
echo $file_xml->body;
?></body>
</html>
Output
Ram
Shyam
Message
Lets do tracking this weekend!
More PHP XML Parser
Visit our PHP XML Parser Reference page to find out more about the XML Parser reference.