10-26-2011 07:01 AM - edited 03-14-2019 08:46 AM
Dear all,
I need to find the phone number (0123456789) in an XML document like this one:
<?xml version="1.0" encoding="UTF-8" ?>
<daily>
<team id="4"><oncall1 id="56">0123456789</oncall1></team>
</daily>
In the Get XML document I have configured the following XML Path
"/descendant::daily/child::team[attribute::id='TEAMID' ]/child::oncall1"
where TEAMID is set to 4
and I have a NULL result !!!!
the goal is to perform
"/descendant::daily/child::team[attribute::id=' " + TEAMVALUE + " ' ]/child::oncall1"
where TEAMVALUE is a variable string.
Please help me finding the issue or at least a way to debug this as I don't know how to debug this :-)
Thanks in advance
Vincent.
10-26-2011 07:24 AM
This is all you should need:
"//team[@id=" + TEAMVALUE + "]/oncall1"
Where TEAMVALUE is an int variable which holds your team ID.
What you can do to debug first, is set this string to a variable, then reactive debug your script, making sure the result looks like this:
"//team[@id=4]/oncall1"
Because the ID value is numeric, the single quotes are not needed. Also, the double forward slash, skips the root element, and just says: "find me a team node whose attribute equals 4." Followed by single forward slash and the oncall1 node name, saying: and return the value of the child node oncall1."
Here's an OK reference for learning some XPATH
10-26-2011 07:32 AM
Dear Anthony,
thanks for your quick answer. I still have a NULL result but I will have a look to the link you provide me to avoid disturbing you for nothing.
thanks again. I will let everybody know the result...
Regards,
Vincent.
10-26-2011 08:58 AM
As another measure of troubleshooting, you shold create a brand new script for just testing your xpath. Then, you can hard code values, and use active debugging versus reactive debugging.
The minimums would be:
Variables:
Document xml = doc[my_xml_doc.xml]
String xpath_target = "//team[@id=4]/oncall1"
String xpath_result = ""
Steps:
xml = Create XML Document(xml) xpath_result = Get XML Document Data(xml, xpath_target)
Good luck, and let us know.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide