Jump to content

XML and xpath


-null-

Recommended Posts

I have the following xml document

 

<links>
  <item>
    <name>[OoE]</name>
    <link>http://blahblahblah.com</link>
    <category>3</category>
  </item>
  <item>
    <name>-FaKe|</name>
    <link>http://moreblah.com</link>
    <category>3</category>
  </item>
  <item>
    <name>Cymru</name>
    <link>http://asdas.com</link>
    <category>3</category>
  </item>
</links>

 

and I use an xpath query to select nodes whose name begins with a certain character.  This is all working well however when I access the nodes using nextSibling I am not getting what I expect.

 

In my foreach

foreach ($nodeList as $node) 
  echo( $node->nodeValue );
  echo( $node->nextSibling->nodeValue );
  echo( $node->nextSibling->nextSibling->nodeValue );
}

 

The first line gives me the value of the name node as I expect. However the second line echos nothing where I would expect the value of link and the third echos the value of link where I would expect category.

 

Is this because the whitespace is being treated as a node and if so can I set it so whitespace is ignored.

Link to comment
https://forums.phpfreaks.com/topic/171054-xml-and-xpath/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.