Groups | Blog | Home
all groups > dotnet framework > december 2007 >

dotnet framework : using System.Net and System.XML Question


Arne_Vajhøj
12/25/2007 10:52:50 PM
[quoted text, click to view]

Try:

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

Mr. Arnold
12/25/2007 10:56:24 PM

[quoted text, click to view]

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. :)

Yasir Zaheer
12/26/2007 2:18:37 AM
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.

[quoted text, click to view]
newscorrespondent@charter.net
12/26/2007 3:41:35 AM

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
newscorrespondent@charter.net
12/26/2007 4:06:54 AM
I think I got the answer. The Address ID is an attribute of a node not the
BELÁK Miloš
12/27/2007 10:06:20 AM
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.
Arne Vajhøj
12/27/2007 8:57:34 PM
[quoted text, click to view]

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

AddThis Social Bookmark Button