Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
10 replies
Subscribers
9 subscribers
Views
3874 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
We are consuming a web service response xml and I am able to retrieve data for s
karlaw
over 12 years ago
We are consuming a web service response xml and I am able to retrieve data for specific tags using this syntax:
if( (xpathsnippet(pv!customersOnAccountResponseBody_Txt, "//*[local-name(.)='ReturnCode']/text()")) = "", "", xpathsnippet(pv!customersOnAccountResponseBody_Txt, "//*[local-name(.)='ReturnCode']/text()") )
The problem with the above results is that I get all instances of the tag "ReturnCode". I only want the data from this tag when its in a particular child tag. How would the syntax change above then?
I have tried absolute and realize path's and neither work....
OriginalPostID-60116
OriginalPostID-60116
Discussion posts and replies are publicly visible
0
karlaw
over 12 years ago
Correction....relative not realize...sorry
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Owen Parrish
Appian Employee
over 12 years ago
In XPath, using "//" says, "Get this node everywhere in the XML no matter where it is." In order to specify only some paths to the node, you will need to give the full path instead. I _think_ something like this should work, /root-element/parent/*[local-name(.)='ReturnCode']/text()")) = ""
"root-element" and "parent" should be replaced as appropriate based on your specific XML structure.
I've always relied on the W3Schools XPath tutorial as a reference.
www.w3schools.com/.../
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mark Talbot
Appian Employee
over 12 years ago
The XPath Tester (
http://www.xpathtester.com/)
is another good tool. It takes an XPath and XML as input and it displays the results from the XPATH transformation.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
Owen - I tried what you stated (this is what I call absolute path) and it fails....
Here is the end tags and the error message. I cannot include the entire error due to confidentiality. The ReturnCode tag I ned to get is within the Account tag.
</Account> </Accounts> </Customer> </GetCustomerAccountsResponseMessage> </GetCustomerAccountsResponse> </soapenv:Body> </soapenv:Envelope>","/GetCustomerAccountsResponse/GetCustomerAccountsResponseMessage/Customer/Accounts/Account*[local-name(.)='ReturnCode']/text()")' (user=kwellman, exprId=268435793) could not be evaluated: An error occurred while trying to evaluate the XPath expression (/GetCustomerAccountsResponse/GetCustomerAccountsResponseMessage/Customer/Accounts/Account*[local-name(.)='ReturnCode']/text()). (APNX-1-4157-003) (Data Outputs)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
This is the exact syntax for the node: if( (xpathsnippet(pv!accountResponseBody_Txt, "/GetCustomerAccountsResponse/GetCustomerAccountsResponseMessage/Customer/Accounts/Account*[local-name(.)='ReturnCode']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "/GetCustomerAccountsResponse/GetCustomerAccountsResponseMessage/Customer/Accounts/Account*[local-name(.)='ReturnCode']/text()") )
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Owen Parrish
Appian Employee
over 12 years ago
It looks like you might be missing a slash after "Account" You also probably need to user the local-name function at every level.
/*[local-name()='GetCustomerAccountsResponse']/*[local-name()='GetCustomerAccountsResponseN=Message']/*[local-name()='Customer']/*[local-name()='Accounts]/*[local-name()='Account']//*[local-name()='ReturnCode']/text()
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
This looks different then my syntax...I'll try this. Thanks!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
is this part a typo? 'GetCustomerAccountsResponseN=Message'?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Owen Parrish
Appian Employee
over 12 years ago
Yes
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
We were able to get this to work but we had to strip off the <soap> tags at the beginning and end of the xml response. Thanks Owen....this was critical to parsing the response! Now if I could just get the boolean logic to work, all my issues will be resolved.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel