I have an XML file that needs parsing in PHP. I am currenlty using simplexml_load_file to load the file like so:
$xml = simplexml_load_file('Project.xml');
Inside that XML file lies a structure like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<name>Project 1</name>
<features>
<feature>Feature 1</feature>
<feature>Feature 2</feature>
<feature>Feature 3</feature>
<feature>Feature 4</feature>
</features>
</project>
What I am trying to do is print the <name>
contents along with EACH <feature>
element within <features>
. I'm not sure how to do this because there is more than 1 element called <feature>
. Any help is greatly appreciated.
to print the text, try this :
foreach($xml->features->feature as $key => $value)
{
echo $value;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With