Solved

Convert xpathnodeiterator  to xmlnodelist

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jaxb jaxp sax dom 7 43
router and equipment 3 74
D3, dragging and rotating. 7 93
MS SQL Database Generating XML using query 21 13
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now