<?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>Parse XML response with xpathsnippet</title><link>https://community.appian.com/discussions/f/general/17695/parse-xml-response-with-xpathsnippet</link><description>hi, 
 I have an xml response containing tags like &amp;lt;a:IsSuccessful&amp;gt;true&amp;lt;/a:IsSuccessful&amp;gt;. And I want to retrieve the value of a:IsSuccessful. 
 I am trying below code but it throws an error- 
 xpathsnippet( pv!response, &amp;quot;//a:IsSuccessful/text()&amp;quot; ) 
 When</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69697?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2019 17:44:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a108dd1c-8f85-45b0-9f0f-18b04a76d652</guid><dc:creator>Robert Shankin</dc:creator><description>&lt;p&gt;Yup.&amp;nbsp; As I noted,&amp;nbsp; xpath seems super easy right up until namespaces are involved.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69685?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 23:39:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7c037554-a5ed-47a6-807b-4fc9b36e7c1c</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Thanks, I see what you mean now - I altered my original sample code to include a fake prefix definition and it seems to work now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69682?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 22:17:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c5d30df3-a053-4254-a63f-a32a5c0decfd</guid><dc:creator>Robert Shankin</dc:creator><description>&lt;p&gt;The namespace prefix is not defined in the original post.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/0753.xpathSnippet.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69680?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 21:07:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b53c0c47-b528-48d6-8c9e-fc4913e7c8b7</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="3416" url="~/discussions/f/general/17695/parse-xml-response-with-xpathsnippet/69679"]Appian does handle this.[/quote]
&lt;p&gt;Can you confirm this?&amp;nbsp; Because when I tried calling &lt;em&gt;xpathsnippet()&lt;/em&gt; on the original poster&amp;#39;s code, I got the following pink error even when just using the xpath &amp;quot;select all&amp;quot; command:&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1569963948628v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Additionally, playing with it in the expression editor, I can&amp;#39;t get any combination of syntax for the xpath expression to&amp;nbsp;&lt;em&gt;not&lt;/em&gt; return this error message when the input string has the &amp;quot;a:&amp;quot; delimiters.&amp;nbsp; Am I still just doing something wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69679?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 20:47:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bdc1bd09-de23-4e9f-9602-04d72ccfe685</guid><dc:creator>Robert Shankin</dc:creator><description>&lt;p&gt;Mike -&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Appian does handle this.&lt;br /&gt;Performing xpath on xml with namespaces is just a bit more complicated than parsing xml without namespaces.&lt;br /&gt;&lt;br /&gt;This is well documented on the web; it&amp;#39;s a common problem people have with xpath, and discussed repeatedly on sites like stackoverflow.&lt;br /&gt;&lt;a href="/members/sayalip"&gt;sayalip&lt;/a&gt; I expect if you do a bit more research on the topic of XML with namespaces and xpath, you&amp;#39;ll have your solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69669?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 15:45:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cb423e63-353c-4984-aa2f-d3f9576ce53b</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Fair enough - though it looks like the current version of&amp;nbsp;&lt;em&gt;xpathsnippet()&lt;/em&gt; doesn&amp;#39;t handle this, so my suggested workaround might still be necessary.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69668?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 15:44:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cb4cc384-4121-4896-bd3f-b92b0a6fe893</guid><dc:creator>Robert Shankin</dc:creator><description>&lt;p&gt; -&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think the syntax checks out.&amp;nbsp; It has to do with namespaces.&lt;br /&gt;&lt;a href="https://www.w3schools.com/xml/xml_namespaces.asp"&gt;https://www.w3schools.com/xml/xml_namespaces.asp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Parse XML response with xpathsnippet</title><link>https://community.appian.com/thread/69666?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 14:27:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4d705ce9-1c04-4014-9b42-e2c2ff7a7abc</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;As far as I can tell, having a colon in the tag name (&amp;quot;a:&amp;quot;) is either against XML best practices, or maybe even plainly not allowed.&amp;nbsp; Refer to the &amp;quot;Best Naming Practices&amp;quot; found here:&amp;nbsp;&lt;a href="https://www.w3schools.com/xml/xml_elements.asp"&gt;https://www.w3schools.com/xml/xml_elements.asp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you have no control over the XML response you&amp;#39;re needing to deal with, I suggest perhaps developing local-side sanitization rules to pass all the XML through first to get the tag names into a format that won&amp;#39;t break xpathsnippet.&amp;nbsp; Maybe something along the lines of:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;xpathsnippet(
  substitute(
    &amp;quot;&amp;lt;a:isSuccessful&amp;gt;true&amp;lt;/a:isSuccessful&amp;gt;&amp;quot;,
    &amp;quot;:&amp;quot;,
    &amp;quot;_COLON_&amp;quot;
  ),
  &amp;quot;//a_COLON_isSuccessful/text()&amp;quot;
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>