PHP SimpleXML – Get Node/Attribute Values

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.
<body>Lets do tracking this weekend!</body>

Get Node Values Example

<!DOCTYPE html>

$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;



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.

People also search
Scroll to Top