Solved

Convert xpathnodeiterator  to xmlnodelist

Posted on 2004-09-28
5
2,079 Views
Last Modified: 2010-05-19
Hi

I hve xpathnodeiterator and want to convert it into xmlnodelist.

Thanks
Ravi
0
Comment
Question by:pprasadravi
  • 2
5 Comments
 
LVL 26

Expert Comment

by:rdcpro
ID: 12174765
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

0
 

Author Comment

by:pprasadravi
ID: 12174810
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
0
 
LVL 26

Accepted Solution

by:
rdcpro earned 500 total points
ID: 12175931
You could create an ArrayList, iterate over the XPathNodeIterator and push each node into the ArrayList.  Then use the ArrayList as your repeater.  But the DocumentFragment is probably just as easy to do, and keeps it all as XML. Document fragments are basically just a lightweight Document object.

Regards,
Mike Sharp
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to parse <assert> tag in XSD1.1 using XSOM Parser? 4 67
VB.Net and XML XSD Files 1 58
parse convert xml feed to text (python) 2 81
XSLT Display Label Name 1 22
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question