<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How do you declare a namespace for proper XPath use within EvaluateXPath in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203423#M83838</link>
    <description>&lt;P&gt;Also an interesting stackoverflow link&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/6390339/how-to-query-xml-using-namespaces-in-java-with-xpath" target="_blank"&gt;https://stackoverflow.com/questions/6390339/how-to-query-xml-using-namespaces-in-java-with-xpath&lt;/A&gt;&lt;/P&gt;&lt;P&gt;it seems that maybe there is a workaround that i can use with evaluatexpath it might look something like the following&lt;/P&gt;&lt;PRE&gt;/*[local-name()='workbook']/*[local-name()='sheets']/*[local-name()='sheet'][1]&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Sep 2018 04:52:11 GMT</pubDate>
    <dc:creator>dave_sargrad</dc:creator>
    <dc:date>2018-09-27T04:52:11Z</dc:date>
    <item>
      <title>How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203420#M83835</link>
      <description>&lt;P&gt;I have made some progress understanding and using EvaluateXPath.&lt;/P&gt;&lt;P&gt;I've been able, for example, to generate a flow file with the content &lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;lt;bookstore&amp;gt;  &amp;lt;book&amp;gt;    &amp;lt;title lang="en"&amp;gt;Harry Potter&amp;lt;/title&amp;gt;    &amp;lt;author&amp;gt;J K. Rowling&amp;lt;/author&amp;gt;    &amp;lt;year&amp;gt;2005&amp;lt;/year&amp;gt;    &amp;lt;price&amp;gt;29.99&amp;lt;/price&amp;gt;  &amp;lt;/book&amp;gt;&amp;lt;/bookstore&amp;gt;&lt;/PRE&gt;&lt;P&gt;and match this using the following (notice &lt;STRONG&gt;//year&lt;/STRONG&gt; as the XPath)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91559-xpathbug3.png" style="width: 1025px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17281i4B04DDA4442DBB46/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91559-xpathbug3.png" alt="91559-xpathbug3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However if I have a namespace in the XML&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91560-xpathbug2.png" style="width: 1040px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17282i531D35BBD9F78990/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91560-xpathbug2.png" alt="91560-xpathbug2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;, then I have a problem (notice &lt;STRONG&gt;//ns8:textNOTAM&lt;/STRONG&gt; as the XPath)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91561-xpathbug1.png" style="width: 1316px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17283i44A196B3DEB6F04D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91561-xpathbug1.png" alt="91561-xpathbug1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 05:12:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203420#M83835</guid>
      <dc:creator>dave_sargrad</dc:creator>
      <dc:date>2019-08-18T05:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203421#M83836</link>
      <description>&lt;P&gt;Oh No!! It looks like there has been an issue outstanding for over 2 years...&lt;/P&gt;&lt;P&gt;Is there no way for me to use EvaluateXPath on XML that contains namespaces?&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/45869/nifi-xml-namespace.html" target="_blank"&gt;https://community.hortonworks.com/questions/45869/nifi-xml-namespace.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://issues.apache.org/jira/browse/NIFI-1023" target="_blank"&gt;https://issues.apache.org/jira/browse/NIFI-1023&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 01:13:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203421#M83836</guid>
      <dc:creator>dave_sargrad</dc:creator>
      <dc:date>2018-09-27T01:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203422#M83837</link>
      <description>&lt;P&gt;Omg.. that worked!! &lt;/P&gt;&lt;P&gt;The XPath I had to use (within the EvaluateXPath processor configuration) was as follows:&lt;/P&gt;&lt;PRE&gt;//*[local-name()='textNOTAM']&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;This is stuff that should live in a NIFI user manual someplace.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 01:43:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203422#M83837</guid>
      <dc:creator>dave_sargrad</dc:creator>
      <dc:date>2018-09-27T01:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203423#M83838</link>
      <description>&lt;P&gt;Also an interesting stackoverflow link&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/6390339/how-to-query-xml-using-namespaces-in-java-with-xpath" target="_blank"&gt;https://stackoverflow.com/questions/6390339/how-to-query-xml-using-namespaces-in-java-with-xpath&lt;/A&gt;&lt;/P&gt;&lt;P&gt;it seems that maybe there is a workaround that i can use with evaluatexpath it might look something like the following&lt;/P&gt;&lt;PRE&gt;/*[local-name()='workbook']/*[local-name()='sheets']/*[local-name()='sheet'][1]&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Sep 2018 04:52:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203423#M83838</guid>
      <dc:creator>dave_sargrad</dc:creator>
      <dc:date>2018-09-27T04:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203424#M83839</link>
      <description>&lt;P&gt;I've found several interesting stack overflow articles.. including the following:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/3931817/xpath-expression-from-xml-with-namespace-prefix" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/3931817/xpath-expression-from-xml-with-namespace-prefix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I should be able to match the book in the following with a simple &lt;STRONG&gt;&lt;EM&gt;//bk:book&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&amp;lt;bk:bookstore xmlns:bk="urn:xmlns:25hoursaday-com:bookstore"&amp;gt;
 &amp;lt;bk:book&amp;gt; 
    &amp;lt;bk:title&amp;gt;Lord of the Rings&amp;lt;/bk:title&amp;gt; 
    &amp;lt;bk:author&amp;gt;J.R.R. Tolkien&amp;lt;/bk:author&amp;gt;
    &amp;lt;inv:inventory status="in-stock" isbn="0345340426" 
        xmlns:inv="urn:xmlns:25hoursaday-com:inventory-tracking" /&amp;gt;
 &amp;lt;/bk:book&amp;gt; 
&amp;lt;/bk:bookstore&amp;gt;
&lt;/PRE&gt;&lt;P&gt;Somehow NIFI needs to let me register the namespace.&lt;/P&gt;&lt;P&gt;I've also tried out online xpath formatters, and they have allowed me to simply add the namespace to the xpath as follows&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.freeformatter.com/xpath-tester.html#ad-output" target="_blank" rel="nofollow noopener noreferrer"&gt;https://www.freeformatter.com/xpath-tester.html#ad-output&lt;/A&gt;&lt;/P&gt;&lt;P&gt;matches //bk:book&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="91562-xpathbug4.png" style="width: 1560px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/17280iB417EC86D9EFEE7D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="91562-xpathbug4.png" alt="91562-xpathbug4.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 05:12:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203424#M83839</guid>
      <dc:creator>dave_sargrad</dc:creator>
      <dc:date>2019-08-18T05:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203425#M83840</link>
      <description>&lt;P&gt;Since I've gotten past this, but i'd like others to understand it as well, i've dug a tiny bit more to understand this "local-name" magic.&lt;/P&gt;&lt;P&gt;Several links of interest&lt;/P&gt;&lt;P&gt;&lt;A href="https://examples.javacodegeeks.com/core-java/xml/xpath/xpath-local-name-example/" target="_blank"&gt;https://examples.javacodegeeks.com/core-java/xml/xpath/xpath-local-name-example/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/local-name" target="_blank"&gt;https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/local-name&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.oracle.com/cd/E35413_01/doc.722/e35419/dev_xpath_functions.htm#autoId6" target="_blank"&gt;https://docs.oracle.com/cd/E35413_01/doc.722/e35419/dev_xpath_functions.htm#autoId6&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.codesimplify.com/java/java-xpath-ignore-namespace-example/" target="_blank"&gt;http://www.codesimplify.com/java/java-xpath-ignore-namespace-example/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Enjoy&lt;/P&gt;</description>
      <pubDate>Fri, 28 Sep 2018 10:19:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203425#M83840</guid>
      <dc:creator>dave_sargrad</dc:creator>
      <dc:date>2018-09-28T10:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203426#M83841</link>
      <description>&lt;P&gt;Instead of using local-name, you can also do this:&lt;/P&gt;&lt;PRE&gt;//*:textNOTAM&lt;/PRE&gt;&lt;P&gt;This has a wildcard for the namespace prefix, and the element name in the place where you would expect it.&lt;/P&gt;&lt;P&gt;This tends to be more readable for longer XPaths like&lt;/P&gt;&lt;PRE&gt;/*:feed/*:entry/*:title&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jul 2019 19:56:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203426#M83841</guid>
      <dc:creator>nverwer</dc:creator>
      <dc:date>2019-07-16T19:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203427#M83842</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/115391/nverwer.html" nodeid="115391"&gt;@Nico Verwer&lt;/A&gt;. I'll give that a shot, and will be sure to accept your response as an answer, once I verify.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 23:23:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/203427#M83842</guid>
      <dc:creator>dave_sargrad</dc:creator>
      <dc:date>2019-07-16T23:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do you declare a namespace for proper XPath use within EvaluateXPath</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/353786#M83843</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/54271"&gt;@nverwer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Instead of using local-name, you can also do this:&lt;/P&gt;&lt;PRE&gt;//*:textNOTAM&lt;/PRE&gt;&lt;P&gt;This has a wildcard for the namespace prefix, and the element name in the place where you would expect it.&lt;/P&gt;&lt;P&gt;This tends to be more readable for longer XPaths like&lt;/P&gt;&lt;PRE&gt;//*:feed//*:entry//*:title&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This info was hard to find.&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/54271"&gt;@nverwer&lt;/a&gt;&amp;nbsp;thanks. Saved my day!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 21:35:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-do-you-declare-a-namespace-for-proper-XPath-use-within/m-p/353786#M83843</guid>
      <dc:creator>Svsio</dc:creator>
      <dc:date>2022-09-30T21:35:52Z</dc:date>
    </item>
  </channel>
</rss>

