Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2007

Tip: Looking for answers? Try searching our database.

using System.Net and System.XML Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
newscorrespondent@charter.net - 26 Dec 2007 03:41 GMT
My XML knowledge is extreemly limited but learning not quite fast enough!

I am getting some XML back from the USPS web service as a string

<?xml version="1.0"?>
<ZipCodeLookupResponse><Address ID="0"><Address2>6406 IVY
LN</Address2><City>GREENBELT</City><State>MD</State><Zip5>20770</Zip5><Zip4>1440</Zip4></Address></ZipCodeLookupResponse>

I create a System.Xml.XmlDocument and then load the string.

How do I access the value of "Address ID=" from within C# code using the
XMLDocument?

From one of my books I think this is an attribute but when I check it tells
me there are no attributes in the document.

Thanks
Tom Groszko
Arne Vajhøj - 26 Dec 2007 03:52 GMT
> My XML knowledge is extreemly limited but learning not quite fast enough!
>
[quoted text clipped - 8 lines]
> How do I access the value of "Address ID=" from within C# code using the
> XMLDocument?

Try:

doc.SelectSingleNode("//ZipCodeLookupResponse/Address/@ID").Value

Arne
Mr. Arnold - 26 Dec 2007 03:56 GMT
> My XML knowledge is extreemly limited but learning not quite fast enough!
>
[quoted text clipped - 12 lines]
> tells
> me there are no attributes in the document.

It's in VB, but you can do the same thing in C#.

http://developer.yahoo.com/dotnet/howto-xml_vb.html

This may help you too in the future.

http://support.softartisans.com/kbview_675.aspx

I feel your pain. I am working on a C# Web service that is to make contact
with a 3rd party Web service to send/receive XML Documents.

I am learning more about XML than I ever cared to know. :)
newscorrespondent@charter.net - 26 Dec 2007 04:06 GMT
I think I got the answer. The Address ID is an attribute of a node not the
document which I was originally checking.
Yasir Zaheer - 26 Dec 2007 10:18 GMT
Actually, the attribute is not "Address ID", it is only "ID"
associated with the node "Address". you can check the values like :
xmlDocument.SelectSingleNode("//ZipCodeLookupResponse/
Address").Attributes["ID"].Value. and this will give you the value of
that attribute.

Regards,
Yasir Zaheer.

On Dec 26, 9:06 am, newscorrespond...@charter.net wrote:
> I think I got the answer. The Address ID is an attribute of a node not the
> document which I was originally checking.
BELÁK Miloš - 27 Dec 2007 09:06 GMT
Prajem pekný deň.
Potreboval by som vygenerovať funkciou Random
číslo do nejakej premennej. V praxi by som chcel
vytvoriť nejaký príklad pre výpočet.
Nech som hľadal ako hľadal, ale nič som rozumné nenašiel.
Nemáte nejaký slušný Netlink, kde by to bolo možné doštudovať?
Dik za pomoc.
S pozdravom Miloš
Arne Vajhøj - 28 Dec 2007 01:57 GMT
> Prajem pekný deň.
> Potreboval by som vygenerovať funkciou Random
[quoted text clipped - 3 lines]
> Nemáte nejaký slušný Netlink, kde by to bolo možné doštudovať?
> Dik za pomoc.

You may get more responses if you try post in english.

Arne

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.