XML is a language that is really good at transporting and storing data. It isn't made to display data. One great feature of XML is that you make up your own tags so that they are more applicable to what you want to do. SimpleXML is an easy way to use php to read XML files. This is going to be an interactive tutorial. By the end of it, you will have a basic understanding of SimpleXML. Hopefully you already know the basics of XML. If not, use this helpful tutorial to learn it. Then come back here. Let's get started!
<?xml version="1.0" encoding="ISO-8859-1"?>Remove the spaces between the question marks and the carrots. Remember to insert the code at the very top of the document with no blank spaces. Blank spaces can interfere with the information we are trying to store.
<message> </message>
<to>Agent 1180463</to> <date>Jan 10</date> <content>Mission #GQ: DO NOT ENTER THE NEST</content> <signature>-X</signature>
<?php $xml=simplexml_load_file("spy.xml"); ?>
print_r($xml);
echo $xml->to . "<br>";
foreach($xml->children() as $element) { echo $element->getName() . ": " . $element . "<br>" . "<br>"; }
Hopefully this tutorial was a useful place to start. I have taken the liberty of attaching a reference guide of functions you can use. I DO NOT OWN IT! It is from W3Schools. You can access the table online here, or you can look at the picture below.