Solved

XMLDocument and XMLnode

Posted on 2004-10-08
2
453 Views
Last Modified: 2012-06-27
I am using a server API that returns XML. Lets say I get the following XML back on a login attempt, how can i check to see if the
<CreateTicketReply url="http://www.abc.com/contoso?ticket=z46tc3gvfwvo"/> node it there.  If it is there, I want to get the value of the url.

<ConfCenter authUser="xxx" authPassword="xxxx">
  <CreateTicketRequest
    <GeneralLoginContext userID="userID"/>
    <CreateTicketReply url="http://www.abc.com/contoso?ticket=z46tc3gvfwvo"/>
  </CreateTicketRequest>
</ConfCenter>

thanks for your time!

0
Comment
Question by:jrmcdona
2 Comments
 
LVL 8

Accepted Solution

by:
Razzie_ earned 250 total points
ID: 12263918
Hi jrmcdona,

This should work:

XmlNode node = xmlDocument.SelectSingleNode("//CreateTicketReply/CreateTicketRequest/CreateTicketReply");
if(node != null)
   Console.WriteLine("The value of the url = " + node.Attributes["url"].Value);
else
   Console.WriteLine("The url node doesn't exist!");

HTH,

Razzie
0
 

Author Comment

by:jrmcdona
ID: 12266911
thanks for your help!

that got it working for me.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

829 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