Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert xpathnodeiterator  to xmlnodelist

Posted on 2004-09-28
5
Medium Priority
?
2,120 Views
Last Modified: 2010-05-19
Hi

I hve xpathnodeiterator and want to convert it into xmlnodelist.

Thanks
Ravi
0
Comment
Question by:pprasadravi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

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 …
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, …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

670 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