xpath

Hi
i developed small application using asp.net,c# which gets the nodelist, from nodelist will get the data based on elementname.Here is the code :
here Utility is my own xml class it returns xmlnodelist.
XmlNodeList mappingnodelist=Utility.GetNodeList("/root/Summary",mapping);
string d1=datanode.SelectSingleNode("FirstName").InnerText
string d2=datanode.SelectSingleNode("LastName").InnerText
string d3=datanode.SelectSingleNode("City").InnerText

Now i want to develop same implementation using xpathdocument,xpathnodeiterator or any method.
Basi reason behind that we can sort with xpathnavigator,xpathexpression.
using xpathdocument i am able to get the xpathnodeiterator.after that i am not sure how to get the value of particular element.it seems always we need to use movenext and it is forward only.

If anybody have clue pls help me.

Note : basi reason i want to sort the xmldocumet(XMLDocument or xpathdocument or xpathdatadocument).

If you simply want to sort the nodelist, based on some value you can get out of each node, you use IComparable to sort. Here's an example from another question I answered. It's untested, and does not exactly do what you want, but then I don't know what criteria you want to sort on.

// Right here you do a test, and compare the nodes using whatever criteria you need to determine which one comes first.
// This example isn't quite correct, since we really want to compare ints, and GetAttribute returns a string.
// Convert to an int, then compare. In your case, probably get the child nodes you want to sort on, and compare.
// IComparer returns one of three things depending on how the two objects compare:
// Less than zero x is less than y.
// Zero x equals y.
// Greater than zero x is greater than y.
// So if you override it, you have to provide a series of tests on your objects that ultimately return -1, 0 or 1.
if (xNode.GetAttribute("Left") < yNode.GetAttribute("Left")) return -1;
if (xNode.GetAttribute("Left") > yNode.GetAttribute("Left")) return 1;
return 0
}

This is my first implementation using xpath.The way i am thinking may be wrong.Pls update me.

Here is my problem how to get the elemet values(Ex: city,firstname and last name).If i know the elemt name can i get the value directly without loopning the list.Here is my Example :
Persons is root node.Header is singlenode.Person may repeat number of times.

My Implementation :

first i want to get header information .next i am want to get all Person nodes.When i have person node i want to get first city,Firstname and Lastname .

i use to use selectsinglenode to get the particular element value.But i am not sure what i need to use it with xpathnodeiterator.

this.nsmanager = new XmlNamespaceManager(xmldocument.NameTable);
this.nsmanager.AddNamespace("ns2", "http://"); // if you have any namespaces you will want to use a nsm
this.nsmanager.AddNamespace("ns1", "http://");

Featured Post

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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 Client Need Led Us to RSS
I recently had an investment company ask me how they might notify their constituents about their newsworthy publications. Probably you would think "Facebook" or "Twitter" but this is an interesting client. Their cons…

Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…