<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Reading an XML file into an Interface</title><link>https://community.appian.com/discussions/f/process/20722/reading-an-xml-file-into-an-interface</link><description>Hi I have a need to be able to select an XML file, and use fields in it to populate an interface. 
 At the moment I have a simpe interface with a File Upload and a Rule Input of xmlData (Document) which the file upload saves to. 
 I am then kicking off</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80853?ContentTypeID=1</link><pubDate>Sat, 10 Apr 2021 01:09:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d72ec108-656e-4311-ad64-a1f0c37ce666</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;The xml example that you provided is not a valid xml, the main problem is that you cannot have a XML tag name with spaces, otherwise the second word would be interpreted as an attribute.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I edited your example in order to make the XML valid, and from there you can adjust to your process. Please find the valid xml in the code below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="xml"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;Root&amp;gt;
	&amp;lt;OriginalVariables&amp;gt;
		&amp;lt;CardholderElement&amp;gt;Carolina Kenny&amp;lt;/CardholderElement&amp;gt;
		&amp;lt;CardNumberElement&amp;gt;449450294&amp;lt;/CardNumberElement&amp;gt;
	&amp;lt;/OriginalVariables&amp;gt;
	&amp;lt;Scanning/&amp;gt;
	&amp;lt;QueueInfo&amp;gt;
		&amp;lt;Company&amp;gt;Parkmill&amp;lt;/Company&amp;gt;
	&amp;lt;/QueueInfo&amp;gt;
&amp;lt;/Root&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Below is the code example for you get the company value:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;xpathdocument(
  docId: YOURDOC,
  expression: &amp;quot;Root/QueueInfo/Company/text()&amp;quot; 
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In case these responses were&amp;nbsp;helpful don&amp;#39;t forget to mark the question as answered as it can also help other that are facing similar issues.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Acacio B.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80839?ContentTypeID=1</link><pubDate>Fri, 09 Apr 2021 08:52:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:20a306a6-77ee-4f34-906e-cf043dd5095f</guid><dc:creator>David Craven</dc:creator><description>&lt;p&gt;HI Acacio&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Your right - I got the first line of code to work within an expression rule, so Im just going wrong somewhere else in the process model.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Regarding the second method, that wouldn&amp;#39;t work, although the structure of the XML file is slightly different - Ive tried replacing fields with Root and Original Variables - if you could let me know the correct syntax for it that would be great (Ive attached it here)&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.appian.com/cfs-file/__key/communityserver-discussions-components-files/14/Client_5F005F005F00_0001_5F00_GIRO_5F00_KTA.XML.xml"&gt;community.appian.com/.../Client_5F005F005F00_0001_5F00_GIRO_5F00_KTA.XML.xml&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80834?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 22:46:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fdf09aad-17ed-4e99-958d-36f17db4ea19</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hey David,&lt;/p&gt;
&lt;p&gt;For the XML that you post as example the first code that I sent in my previous answer should work, as I tested it in my local environment.&lt;/p&gt;
&lt;p&gt;In order to speed up your tests you could upload a file to Appian and test it in an expression rule, just past the code that I sent and change the docId, in case it is working in the expression and failing in your process model you need to analyse in detail the steps in your PM.&lt;/p&gt;
&lt;p&gt;Let me know,&lt;/p&gt;
&lt;p&gt;Regards.&lt;/p&gt;
&lt;p&gt;Acacio B.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80801?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 10:12:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bcfd86a6-8486-43e9-b1b1-d74bf20ab52a</guid><dc:creator>David Craven</dc:creator><description>&lt;p&gt;Just wondering - when I test the interface it is passing in the doc id and name into the rule input&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/14/pastedimage1617876755592v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;BUt in the Process Model where it is passed into a parameter it is just the name&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/14/pastedimage1617876725657v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Would that be effecting it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80800?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 10:10:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d1ac2c4f-56a3-4148-b065-f61295116b49</guid><dc:creator>David Craven</dc:creator><description>&lt;p&gt;Hi Acacio&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for that.&amp;nbsp; I&amp;#39;ve tried using both snippets of your code (replacing YOURDOC with pv!xmlFile, with each XML file but get the same error each time&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/14/pastedimage1617875291241v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/14/pastedimage1617875355668v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Not sure where it is going wrong, have tried putting a tointeger() around the pv!xmlFile just in case&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/14/pastedimage1617875875791v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;David&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80796?ContentTypeID=1</link><pubDate>Thu, 08 Apr 2021 00:06:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f8821bb7-750a-46f3-82c2-4c45c359521e</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;Yes, there is a big difference in relation to the format of your XML.&lt;/p&gt;
&lt;p&gt;In the current format as you sent in your example, the data that you are trying to retrieve is stored in one of the attributes from of the field called Field. This field is generated multiple times in your XML and the only difference between them is the values in the attributes (Field Name and value). It is possible to get the value that you are looking for, by AFAIK, you would need to rely on indexes, I&amp;rsquo;m attaching a code below where that you can use to get the Company value:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;xpathdocument(
  docId: YOURDOC,
  expression: &amp;quot;Document/Fields/Field[2]/@Value&amp;quot; 
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On the other hand, using the second format that you proposed you could easily get the value from company without need to rely on index. I&amp;rsquo;m attaching a code example below:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;xpathdocument(
  docId: YOURDOC,
  expression: &amp;quot;Document/Fields/Company/text()&amp;quot; 
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Acacio B.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80776?ContentTypeID=1</link><pubDate>Wed, 07 Apr 2021 14:33:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:de0c1ab5-47ed-4b5d-ba3d-0c7c1bcddbef</guid><dc:creator>David Craven</dc:creator><description>&lt;p&gt;Ok thanks all&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve attached a copy of the sample XML I am using - dont think there is a namespace?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Currently the field data I am trying to grab from the XML is:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span&gt; &lt;/span&gt;&amp;lt;Field Name=&amp;quot;Company&amp;quot; Value=&amp;quot;Park Mill&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt;and this is the expression in the Process Model Script Task&lt;/p&gt;
&lt;p&gt;=xpathdocument( &lt;br /&gt; docID: pv!xmlFile, &lt;br /&gt; expression: &amp;quot;/Document/Fields/Field[@Name='Company']/@Value&amp;quot;&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;Also, I just wondered what difference it would make if the XML fields were in the following format:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Company&amp;gt;Parkmill&amp;lt;/Company&amp;gt;&lt;/p&gt;
&lt;p&gt;Would the expression need to be different?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.appian.com/cfs-file/__key/communityserver-discussions-components-files/14/Sample-XML-1-_2D00_-General-Correspondence-CG-_2800_3_2900_.xml"&gt;community.appian.com/.../Sample-XML-1-_2D00_-General-Correspondence-CG-_2800_3_2900_.xml&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80765?ContentTypeID=1</link><pubDate>Wed, 07 Apr 2021 01:28:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:68528a00-512e-4287-a3d3-dd885642b974</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;As pointed out by Mike, you don&amp;rsquo;t need to worry about the document Id, looking into the documentation for the function &amp;ldquo;xpathdocument&amp;rdquo;, we can see that the parameter docId is Any Type, and it would accept both, document or document Id. Therefore, there was nothing wrong in your implementation.&lt;/p&gt;
&lt;p&gt;Documentation Reference:&lt;/p&gt;
&lt;p&gt;docId (Any Type): Xml Document id or Content Item (Document).&lt;/p&gt;
&lt;p&gt;About the name space, it is normally defined in the root node of the XML, it can be also defined direct in one of the XML nodes, so you need to check it in your XML file. An easy way to check is looking for prefixes in the child nodes or in the root node.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m adding a sample XML from w3schools, in it you will be able to see two name spaces with different prefix (h and f), so lets say that you want to return the child &amp;lt;f:name&amp;gt; under the node &amp;lt;f:table&amp;gt;, so you would need to add in the function parameter prefix, something like that:&lt;/p&gt;
&lt;p&gt;prefix: &lt;a href="https://www.w3schools.com/furniture"&gt;&amp;quot;f:https://www.w3schools.com/furniture&amp;quot;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="xml"&gt;&amp;lt;root xmlns:h=&amp;quot;http://www.w3.org/TR/html4/&amp;quot; xmlns:f=&amp;quot;https://www.w3schools.com/furniture&amp;quot;&amp;gt;
	&amp;lt;h:table&amp;gt;
		&amp;lt;h:tr&amp;gt;
			&amp;lt;h:td&amp;gt;Apples&amp;lt;/h:td&amp;gt;
			&amp;lt;h:td&amp;gt;Bananas&amp;lt;/h:td&amp;gt;
		&amp;lt;/h:tr&amp;gt;
	&amp;lt;/h:table&amp;gt;
	&amp;lt;f:table&amp;gt;
		&amp;lt;f:name&amp;gt;Coffee Table&amp;lt;/f:name&amp;gt;
		&amp;lt;f:width&amp;gt;80&amp;lt;/f:width&amp;gt;
		&amp;lt;f:length&amp;gt;120&amp;lt;/f:length&amp;gt;
	&amp;lt;/f:table&amp;gt;
&amp;lt;/root&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I hope this helps you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80764?ContentTypeID=1</link><pubDate>Wed, 07 Apr 2021 01:26:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1292520e-9cd9-4807-b24c-788dcb326160</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi Mike,&lt;/p&gt;
&lt;p&gt;I totally agree with you,&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Acacio B.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80759?ContentTypeID=1</link><pubDate>Tue, 06 Apr 2021 16:11:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9b7bfcaa-ba42-4954-872f-3d68534f30dc</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="36529" url="~/discussions/f/process/20722/reading-an-xml-file-into-an-interface/80756#80756"]How would I find the DocumentID?&amp;nbsp; [/quote]
&lt;p&gt;Your assumptions are correct, as long as you account for needing to submit a form prior to accessing a document&amp;#39;s properties (which i believe you&amp;#39;re already doing correctly).&amp;nbsp; If needed, you can always typecast a document object directly to its ID by, among other things, passing the document object through the &amp;quot;toInteger()&amp;quot; function.&amp;nbsp; As I noted in my prior reply though, in almost all cases it won&amp;#39;t make any difference, as integer and document objects will almost seamlessly cross-typecast as needed depending on the service in question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80758?ContentTypeID=1</link><pubDate>Tue, 06 Apr 2021 16:08:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bd01ceb3-4015-468c-871a-ba3bae6fe180</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="33453" url="~/discussions/f/process/20722/reading-an-xml-file-into-an-interface/80745#80745"]The input for the expression should be the document ID and not the document itself[/quote]
&lt;p&gt;So just FYI... in almost all cases, there will be no difference, as the &amp;quot;document itself&amp;quot; (assuming you&amp;#39;re referring to an object of type &amp;quot;Appian Document&amp;quot;) is really just the document&amp;#39;s ID, and use cases that require the ID will almost always typecast the document down to its integer ID if necessary.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80756?ContentTypeID=1</link><pubDate>Tue, 06 Apr 2021 14:09:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4b52f2bd-8ae9-4515-9a29-4cc134e822a8</guid><dc:creator>David Craven</dc:creator><description>&lt;p&gt;Hi Acacio&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How would I find the DocumentID?&amp;nbsp; This is my interface - I assume it is the 47259 stored in the rule input before the filename?&amp;nbsp;&amp;nbsp;What would be the best way of grabbing this in the process model?&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/14/pastedimage1617717997441v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Also, where do I check for if the xml has namespace?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is the document properties of one I uploaded&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/14/pastedimage1617718215014v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;br /&gt;David&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading an XML file into an Interface</title><link>https://community.appian.com/thread/80745?ContentTypeID=1</link><pubDate>Tue, 06 Apr 2021 03:40:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dca8cb4a-f81e-45ce-8ebe-988b86a88baf</guid><dc:creator>Acacio Barrado</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;Few recommendations that I could give to you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The input for the expression should be the document ID and not the document itself&lt;/li&gt;
&lt;li&gt;Check in your xml file if you have namespaces defined, in case you need, it needs to be a parameter in the expression&lt;/li&gt;
&lt;li&gt;If you are trying to retrieve just the text out of one xml tag try to use &lt;em&gt;&amp;ldquo;/text()&amp;rdquo;&lt;/em&gt; instead &lt;em&gt;&amp;ldquo;/@value&amp;rdquo;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;m adding a sample code below, in this example only the text of the tag &amp;quot;content&amp;quot; is retrieved:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;xpathdocument(
  docId: 9999,
  expression: &amp;quot;/a:document/data/body/item/content/text()&amp;quot;,
  /*sample namespace prefix just add if your input xml has ns*/
  prefix: &amp;quot;a:http://www.appian.com/ae/types/2009&amp;quot;
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Acacio Barrado.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>