• Advertisement
Sign in to follow this  

[.net] XPath and SelectNodes [Solved]

This topic is 3736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hola, I've hit a problem with trying to sieve some data from an XML document. the document has something like the following. <Row> <Col><Data id='1'>Hello</Data></Col> <Col></Col> </Row> <Row> <Col></Col> </Row> <Row> <Col><Data id='2'>Hello</Data></Col> <Col><Data id='3'></Data></Col> </Row> and so on. Now, I'm wanting to get a XmlNodeList of rows that only have a Data element within its children, is this possible using a single call to SelectNodes using XPath ? I've tried looking at contains() but this requires two params and I'm not sure what I'd put as the second param as the element may not have any text. I've also though about the idea of getting all the Data elements in a list and using the parent member and indexof to work out indices, but with past experience of indexof it can get very slow. Any pointers will be greatly appreciated. Regards, Nik. [Edited by - Niksan2 on October 30, 2007 6:20:51 AM]

Share this post


Link to post
Share on other sites
Advertisement
Nevermind, as always I solved it after posting :)

.//Row[Col/Data] did the trick.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement