Link to home
Start Free TrialLog in
Avatar of LeeDerbyshire
LeeDerbyshireFlag for United Kingdom of Great Britain and Northern Ireland

asked on

(Advanced?) GetElementsByTagName question

Suppose part of my XML response looks like this:

<t:ExtendedProperty>
 <t:ExtendedFieldURI PropertyTag="0x3fd9" PropertyType="String" />
 <t:Value>Hello 1</t:Value>
</t:ExtendedProperty>
<t:ExtendedProperty>
 <t:ExtendedFieldURI PropertyTag="0x10f3" PropertyType="String" />
 <t:Value>Hello 2</t:Value>
</t:ExtendedProperty>

How can I use getElementsByTagName to get the second value?  If I use "t:Value", I get the first one, of course, but how can I use the PropertyTag value to tell it that I want the second t:Value ?
ASKER CERTIFIED SOLUTION
Avatar of mvgeertruyen
mvgeertruyen
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeeDerbyshire

ASKER

Do you have a pointer to a simple XPath example that would work in a situation like this?  I would like the be able to do something like:
getElementsByTagName("t:ExtendedFieldURI[PropertyTag="0x10f3"]/t:Value")
Sorry to seem so dense, but I just can't seem to get it working.  From what I've read, this should work:

getElementsByTagName("t:ExtendedFieldURI[@PropertyTag="0x10f3"]/t:Value")

but it doesn't.
Ugh, I just noticed a small, but significant, complication.  The t:ExtendedFieldURI field has a closing / within the tag.  Which, of course, means that t:Value isn't a child of it (obvious, now).  I think I need to use it's ancestor - I'll see what I can find out about it.
Okay, I have it:

//t:Value[ancestor::t:ExtendedProperty/t:ExtendedFieldURI/@PropertyTag=""0x1090""]

Doesn't work with GetElementsByTagName, though.  I have to use SelectSingleNode