Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I've currently got a webpage which processes some information from an XML document.
OK, I've loaded the XML document like so...
[syntax="xml"]<?xml version="1.0" encoding="ISO-8859-1"?>
<gallery>
<photo>
<file>08.gif</file>
<caption>Something</caption>
</photo>
<photo>
<file>09.gif</file>
<caption>Something</caption>
</photo>
<photo>
<file>10.gif</file>
<caption>Something!</caption>
</photo>
</gallery>
Code: Select all
$dom = new DomDocument();
$dom -> load("xml/gallery.xml");
$xp = new DomXPath($dom);
$count = //query and retrieve count.So in the above XML document, I'd need it to return "3" because there are 3 <photo> nodes.
Also is there a way of being able to retrieve an index value of a particular node? So say if I pass a value "10.gif" into a function, it would return an index of "3" because it's the 3rd <photo> node under the element <gallery>.
That way I am able to use the index value and compare it to "count" to determine if I've reached the end of the XML document.
If there's an easier way, please tell me. As I'm new to this whole thing.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]