title: How to query XML with namespaces in Oracle?
body: <p>I need to extract data in PLSQL procedure from XMLType variable containing complete XML document, with following structure (below simplified):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;AA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://my.domain/cat1/"&gt;
    &lt;Element&gt;
      &lt;ID&gt;2&lt;/ID&gt;
      &lt;Value&gt;46544&lt;/Value&gt;
    &lt;Element&gt;
  &lt;/AA&gt;
  </code></pre>
  
  <p>I'm using XMLTable function, but with simple <code>/AA/Element</code> XPath expression getting no data:</p>
  
  <pre><code>SELECT C1, C2
  INTO v_id, v_val
  FROM XMLTable('/AA/Element'
                     passing v_MyXML columns
                      C1 number path 'ID',
                      C2 number path 'Value'
                  )
  </code></pre>
  
  <p>Neither with any of below expressions:</p>
  
  <pre><code>'/*.AA/Element'
  'declare default element namespace "http://my.domain/cat1/"; /AA/Element'
  'declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; declare namespace xsd="http://www.w3.org/2001/XMLSchema"; declare default element namespace "http://jpk.mf.gov.pl/wzor/2016/03/09/03094/"; /AA/Element'
  </code></pre>
  
  <p>Only way I was able to extract the data was to modify document/variable and simply replace</p>
  
  <pre><code>&lt;AA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://my.domain/cat1/"&gt;
  </code></pre>
  
  <p>with </p>
  
  <pre><code>&lt;AA&gt;
  </code></pre>
  
  <p>It's not the perfect solution as I need to modify the document and return it's initial structure with proper attributes.
  Could anybody suggest how to modify XPath expression to be able to fetch data?
  Or maybe use any other method ignoring namespaces from AA element?</p>