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
4068 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Hi All, I am trying to get xml data using xpathdocument(), The xml do
Venu
over 9 years ago
Hi All,
I am trying to get xml data using xpathdocument(), The xml document is saved in Appian(As attachment).
xml document contains attribute xmlns="
http://www.adatum.com"
at the root element. with out this attribute I can get the xml data. what could be the possible xpath expression.
xpathdocument(ri!doc,"//Tests")
Thanks.
testXml.xml
OriginalPostID-184414
OriginalPostID-184414
Discussion posts and replies are publicly visible
Top Replies
Venu
over 9 years ago
+1
Below is the code and attaching XML load( a!paragraphField( value:torecord(xpathdocument(95893,"/root/data"),ri!test), height:"TALL" ) ) here ri!test is the input to the interface of custom type (CDT Array…
0
PhilB
A Score Level 1
over 9 years ago
If you want to get an array of each Test within the Tests element, your xpath expression needs to be /*[name()='Tests']/*[name()='Test'] as this should avoid the issue caused by the namespacing.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Venu
over 9 years ago
Phil, Thanks for your reply
i used the above xpath, but "xmlns="
http://www.adatum.com"
is appended to the result (to the Test element as below).
======================
<Test xmlns="
http://www.adatum.com"
TestId="0001" TestType="CMD">
<Name>Convert number to string</Name>
<CommandLine>Examp1.EXE</CommandLine>
<Input>1</Input>
<Output>One</Output>
</Test>;
======================
Any suggestions.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
The namespace being attached is expected as it's part of the top level XML and so is replicated on the result you extract. What exactly are you trying to extract? If you're able to provide that, I might be able to tell you what expression to use.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Venu
over 9 years ago
What i need exactly is the xml contains 3 Test information, i need to save three records in CDT
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
You'll need to create a rule that returns your CDT (example below) and then apply that rule across the result of the xpathdocument() using "/*[name()='Tests']/*[name()='Test']".
type!myCDT(
name: xpathsnippet(ri!xml, "/*[name()='Test']/*[name()='Name']/text()")
commandLine: xpathsnippet(ri!xml, "/*[name()='Test']/*[name()='CommandLine']/text()"
input: xpathsnippet(ri!xml, "/*[name()='Test']/*[name()='Input']/text()"
output: xpathsnippet(ri!xml, "/*[name()='Test']/*[name()='Output']/text()"
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Venu
over 9 years ago
Thanks Phil,
i have another question,
i have an xml file of 3 records(rows) and that didn't have namespace.
i used xpathdocument and torecord functions to save data in my cdt variable.
xpathdocument give 3 records correctly, but torecord saves only the last row even the type variable is multiple (Array).
this issue was resolved by some work around.
here my question is: what could be the reason torecord saves only last record/row?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
Could you post the xml and related expressions?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Venu
over 9 years ago
Below is the code and attaching XML
load(
a!paragraphField(
value:torecord(xpathdocument(95893,"/root/data"),ri!test),
height:"TALL"
)
)
here ri!test is the input to the interface of custom type (CDT Array)
newxml.xml
Cancel
Vote Up
+1
Vote Down
Sign in to reply
Verify Answer
Cancel