Click to See Complete Forum and Search --> : XPath expression


Mike74
July 23rd, 2001, 08:29 AM
Hi

I use the XML Path Language (XPath) and have now a problem to get a value from an XML-document. I tried to get the value of the floor-attribute with the following expression:

/Addresses/PostalAddress[@addressId='a1']/AddressPersonInformation/AddressExtention/@floor

It doesn't work, but when I want to get an other attribute on the PostalAddress, i.e.:

/Addresses/PostalAddress[@addressId='a1']/@addressLanguage

it works.

How must be the syntax from the first example to get the value ?

Thanks a lot.
Mike

tyris
July 25th, 2001, 06:10 AM
could you post the xml structure also ?

by the way you do have a wonderfull web application to download (a simpel small zip) to test your own XPath, you link your file, put your XPath expression and the rest is done.. really great (and it's free)

you can get it here :

http://www.vbxml.com/downloads/default.asp?id=cnt182

hope this helped

regards

Elise, XML learning girl :-)

Mike74
July 25th, 2001, 07:06 AM
Thanks for your link to the tool, I'll download it later...Here I try to post you also the XML (its not complete but the problem elements are in it):

You find the XML on

http://mypage.bluewin.ch/yourchoice/mike/Addresses.xml

tyris
July 25th, 2001, 08:09 AM
okay so i tested your XPath in XPath visualiser and you wereright, it's wrong
to good version is :

//Addresses/PostalAddress[@addressId='a1']/AddressPersonInformation/AddressExtension[@floor]

or

/Addresses/PostalAddress[@addressId='a1']/AddressPersonInformation/AddressExtension[@floor]

if you are already in order node




regards

Elise, XML learning girl :-)