Hello MMOwned.
In this guide i will learn you how to parse XML in a simple and easy way with PHP!
Whats recommended to know:
Simple PHP knowledge
Simple HTML knowledge
Okay first we will make our XML file.
We will just put some random things in it like this:
example.xml:
Code:
<person>
<firstname>Edward</firstname>
<lastname>Johnson</lastname>
<age>78</age>
<email>[email protected]</email>
<username>Edwii</username>
<password>edward123</password>
</person>
Please note this is only for examples! I don't know if any user here has the username Edwii xD
Now lets start on the PHP.
First we would of course make the
thats pretty logic right? xD
now what to do? :'(
now lets load the XML file!
for this we will use a function named simplexml_load_file()
we're gonna make our own function!
Now lets continue.
Lets make our function
to make functions (its pretty easy) we simply do like this:
Code:
<?php
function YourFunction() {
}
?>
Now we won't name our function YourFunction.
We will name it XMLoad 
Code:
<?php
function XMLoad() {
}
?>
but there is something wrong.
What is wrong?
Yep thats right.
The functions does absolutely NOTHING!
And to make it possible to load XML we will have to add a parameter to the function.
Like this:
Code:
<?php
function XMLoad($xmlfile) {
echo $xmlfile;
}
?>
Now try and do like this under the function:
wow it writes heey on the page.
Now you got a working function.
Now lets make it work with loading xml!
The function needs to look like this:
Code:
<?php
function XMLoad($xmlfile) {
$xml = @simplexml_load_file($xmlfile);
if(!$xml) {
echo "Unable to load XML File!";
}
else {
}
}
?>
now the XMLoad function can load a XML file but it does not output anything. Is that wierd or wierd? NOT AT ALL! 
To make it display we will have to do like this:
Code:
$xml->person->firstname.
pretty hard huh?
now lets make the function print all of the things in the XML file
Code:
<?php
function XMLoad($xmlfile) {
$xml = @simplexml_load_file($xmlfile);
if(!$xml) {
echo "Unable to load XML File!";
}
else {
echo "<h1>Person Info</h1>First name: " . $xml->person->firstname . "<br>
Last name: " . $xml->person->lastname . "<br>
Age: " . $xml->person->age . "<br>
E-mail: " . $xml->person->email . "<br>
Username: " . $xml->person->username . "<br>
Password: " . $xml->person->password . "<br>";
}
}
?>
now the function is finished.
Now we only need to do one thing.
Save the function as person.php
now make a new php file named index.php
and in that file write this:
Code:
<?php
include("person.php");
XMLoad("example.xml");
?>
Now it should echo all the information of the person Edward Johnson if just you saved the example XML file as example.xml 
Thats was all of this tutorial.
Greetings, NerieX.