Hi.
I've got this simple xml file:

<?xml version="1.0" encoding="utf-8"?>
<items>
<item>
<time>1169838286</time>
<title>Tre</title>
<author>Tre</author>
<content>TRE his module defines a number of classes, which are explained in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.&#13;
This module defines a number of classes, which are explained in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.TRE
</content>
</item>
<item><time>1169838</time>
<title>Tre</title>
<author>Tre</author>
<content>TRE his module defines a number of classes, which are explained in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.&#13;
This module defines a number of classes, which are explained in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.TRE
</content>
</item>
<item>
<time>11698286</time>
<title>Tre</title>
<author>Tre</author>
<content>TRE his module defines a number of classes, which are explained in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.&#13;
This module defines a number of classes, which are explained in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.TRE
</content>
</item>
</items>

To get all the item nodes I've
got this code:

$xp = new domxpath($dom);
$titles = $xp->query("/items/item");
foreach ($titles as $node) {
   print $node->firstChild->data . "\n";
} 

Is there a way
to get only the item with
time=1169838 for instance ?

I'm looking for good tutorials
to using domxpath 😉

Thanks in advance.

Bye.

    Use a predicate that says that the item node's time node's text node has that value (Heh, the XPath is easier to read).

    /items/item[time/text()='1169838']

    Oh, right, tutorials. I don't know any tutorials: I got everything I know about XPath from the source, but I used XPath Explorer to check the above code.

      Thanks a lot buddies 😃

      I used XPath Explorer to check the above code

      It's very useful !

      Bye.

        Write a Reply...