Solved

XMLDocument and XMLnode

Posted on 2004-10-08
2
450 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

17 Experts available now in Live!

Get 1:1 Help Now