Hi,
I have the following XML content in a file (main.xml):
<?xml version="1.0" encoding="iso-8859-1"?>
<menu>
<option title="Home" href="home.php">
<option title="News" href="news.php">
<option title="Recent News" href="recentnews.php" />
<option title="Archive" href="archive.php" />
</option>
<option title="About me" href="news.php" />
<option title="Disclaimer" href="news.php" />
</option>
<option title="Gallery" href="gallery.php">
<option title="Paintings" href="paintings.php" />
<option title="Drawings" href="drawings.php" />
</option>
<option title="Links" href="links.php" />
<option title="Contact" href="contact.php" />
</menu>
I am using the following code to hopefully output the name of the first
node by traversing the tree:
$xml_doc = domxml_open_file('xml/main.xml');
$node = $xml_doc->document_element(); //find the xml root
$node = $node->first_child(); //locate the first_child node
print $node->node_name(); //output the node name
Unfortunetely, when I go run it - instead of outputing 'option', it
outputs:
#text
Im just starting with this but I also hope to output the attributes
too. How would I do this for just the first node using something
similar to the code above?
Can somebody please start me of on the right foot. What I hope to do is
to build a script that will traverse each node in order. Ill probably
have more questions as I learn more about what Im trying to do. Cheers
Burnsy