Solved

Get value from XPathNavigator

Posted on 2006-11-28
3
510 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
[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
3 Comments
 
LVL 30

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.

733 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