Solved

Get value from XPathNavigator

Posted on 2006-11-28
3
501 Views
Last Modified: 2012-06-21
Hi,

I have XPathNavigator,

Now If I get the errors node in the XPathNavigator, then I want the complete errors node into the string

XPathNavigator nav

            XPathNodeIterator iterator = nav.Select("//errors");  

Can anyone help me to get the errors node in the string

Kind Regards
           
0
Comment
Question by:dinesh_bali
3 Comments
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 18033211
First, you have a set of nodes from the select().
So you may need to walk through all of them.

Convert the error element (I assume it's an XmlElement) - depends on the element structure.
It's better if you know it.
I assume it's simple one, e.g.:

<error id="1234">Some info about the error</error>

In this case you do something like:

            XPathNodeIterator iterator = nav.Select("//errors");

            foreach (XmlNode node in iterator)
            {
                string errorText = (node as XmlElement).InnerText;
                Debug.WriteLine(errorText);
                // or
                string errorID = (node as XmlElement).GetAttribute("id");
                Debug.WriteLine(errorID);
               
            }
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 18036267
can u post ur xml file
0
 

Author Comment

by:dinesh_bali
ID: 18042703
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
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…

760 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

22 Experts available now in Live!

Get 1:1 Help Now