>  >  Is that possible?  Or is this something I'd have to do programatically
>  >  using the nodes returned by the XPath query?  Basically, I'm just
>  >  trying to get a fragment of the larger xml document...
>  //[EMAIL PROTECTED]'gc3']/child/ancestor-or-self::*

Thanks for the response.  However, I must be doing something wrong
here.  The test script below isn't doing what I'm expecting:

  $xml = '<?xml version="1.0" encoding="UTF-8"?><root><child
id="c1"><child id="gc1"><child id="ggc1">Great Grand Child
1</child><child id="ggc2">Great Grand Child 2</child></child><child
id="gc2"><child id="ggc3">Great Grand Child 3</child><child
id="ggc4">Great Grand Child 4</child></child></child><child
id="c2"><child id="gc3"><child id="ggc5">Great Grand Child
5</child><child id="ggc6">Great Grand Child 6</child></child><child
id="gc4"><child id="ggc7">Great Grand Child 7</child><child
id="ggc8">Great Grand Child 8</child></child></child></root>';

  $doc = new DOMDocument('1.0', 'UTF-8');
  $doc->loadXML( $xml );

  $xpath = new DOMXPath($doc);
  $nodeList = $xpath->query("//[EMAIL 
PROTECTED]'gc3']/child/ancestor-or-self::*");

  echo 'Got list list of [' . $nodeList->length . '] nodes:<br>';
  for ($i = 0; $i < $nodeList->length; $i++) {
      echo $nodeList->item($i)->nodeValue . "<br>\n";
  }

When I run the XPath query through XMLSpy, the correct nodes are
returning.  However, when I run it through DOMXPath->query() (or
evaluate() for that matter), it doesn't seem to be returning the
correct nodes.

What's going wrong?

thnx,
Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to