Solved

Convert xpathnodeiterator  to xmlnodelist

Posted on 2004-09-28
5
2,088 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML namaspace 2 53
Checkbox and ListView in Android Layout 4 76
XML & .net 5 49
In sql, how to roll up multiple rows to only one row. 4 35
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.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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