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
8 replies
Subscribers
9 subscribers
Views
3375 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Here we go...another XML question :) I was under the impression that
karlaw
over 12 years ago
Here we go...another XML question :)
I was under the impression that using this type of syntax would check to see if a tag exists however, it's really only checking to see if there is any value in an existing tag.
if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='ProductTypeCode']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='ProductTypeCode']/text()") )
What I need to do is determine if a child tag exists or not. If it exists, I want to take the value. If it doesn't, I don't want to store an empty string value in the CDT equivalent field.
Any ideas how the syntax would look for that?...
OriginalPostID-60871
OriginalPostID-60871
Discussion posts and replies are publicly visible
0
karlaw
over 12 years ago
Sorry...typo...I do want to store an empty string value if the child tag does not exist.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Owen Parrish
Appian Employee
over 12 years ago
Have you tried using the XPath boolean() function I mentioned here:
forum.appian.com/.../b-50613
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
I replied to that when I remembered I had asked this question a few months ago. I am trying the boolean function..but with no success yet.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
This syntax doe not return a boolean response like I as hoping....
xpathsnippet("<GetCustomerAccountsResponse></GetCustomerAccountsResponse>", "boolean(//ProductTypeCode)")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
tmalaher
over 12 years ago
try (off the top of my head, so syntax may not be correct):
count("//*[local-name(.)='ProductTypeCode']")
This will give you the *number* of elements that match the condition. Then test to see if this is zero or non-zero. This will tell you if the element exists.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Owen Parrish
Appian Employee
over 12 years ago
You're correct that it does not return a Boolean type. Using typename(runtimetypeof()) it returns a List of Text String. The Text String is either "true" or "false."
Try: exact("true", xpathsnippet("<GetCustomerAccountsResponse></GetCustomerAccountsResponse>", "boolean(//ProductTypeCode)")[1])
That expression returns a Boolean type.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 12 years ago
No luck....no value is being stored in the test boolean. I cut/paste right from the forum. For the account I am using, there are 0 instances of ProductTypeCode so I left the [1]. The application will be looking for multiple instances of ProductTypeCode...it is in a child object <Account> that can repeat any number of times. I want to save the <ProductTypeCode> value when the tag exists and when the tag doesn't exist, I want to save an empy string. All of this will go into a multple PV array.
aTempAccount_Ary
CustomerID
AccountID
ProductTypeCode
XML Response Structure
<GetCustomerAccountsResponse>
<GetCustomerAccountsResponseMessage>
<Customer>
<Accounts>
<Account>
<ProductTypeCode>
</Account>
<Account>
**missing ProductTypeCode tag
</Account>
<Account>
<ProductTypeCode>
</Account>
</Accounts>
</Customer>
</GetCustomerAccountsResponseMessage>
</GetCustomerAccountsResponse>
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
shelzle
over 12 years ago
Having a look at
stackoverflow.com/.../xpath-for-missing-node
you might be able to do two xpath. The first for all accounts with a producttypecode, the second for all without one.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel