Link to home
Start Free TrialLog in
Avatar of pprasadravi
pprasadravi

asked on

Convert xpathnodeiterator to xmlnodelist

Hi

I hve xpathnodeiterator and want to convert it into xmlnodelist.

Thanks
Ravi
Avatar of rdcpro
rdcpro
Flag of United States of America image

I assume you've tried a cast, and it didn't work?  It's kind of weird going from XPathNodeIterator to XmlNodeList...I can't help thinking there's a better way of accomplishing whatever it is you're trying to do.

You create an XpathNodeIterator from a XPathNavigator select:

XPathDocument Doc = new XPathDocument(FileName);
XPathNavigator nav = Doc.CreateNavigator();
XPathNodeIterator Iterator = nav.Select("/bookstore/book");

If you're wanting to go back, the Iterator.current property will return an XPathNavigator, which you use to find the preceding and following siblings. You can't safely navigate away from the current node using the XPathNavigator, unless you clone it first.  

If you really want to create an instance of an XmlNodeList class that contains the nodes in the XPathNodeIterator, then I suppose you'd have to create a XmlDocumentFragment, iterate through the nodes in the XPathNodeIterator, importing each one to the XmlDocumentFragment, then use the ChildNodes property of the XmlDocumentFragment.  

Regards,
Mike Sharp

Avatar of pprasadravi
pprasadravi

ASKER

hi

i am using repeater for presentation and my datasource is xpathnodeiteration.It is totally mess.So i don't know how can i solve this issue.

I found like xmlnodelist can use as datasource.so i am trying my to convert xpathnvigator to xmlnodelist.

If you have better idea i will go for that
Thanks
Ravi
ASKER CERTIFIED SOLUTION
Avatar of rdcpro
rdcpro
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial