title: How to flatten an XML file into a set of xpath expressions?
body: <p>Consider I have the following example XML file:</p>
  
  <pre><code>&lt;ns1:create xmlns:ns1='http://predic8.com/wsdl/material/ArticleService/1/'&gt;
     &lt;article xmlns:ns1='http://predic8.com/material/1/'&gt;
        &lt;name xmlns:ns1='http://predic8.com/material/1/'&gt;foo&lt;/name&gt;
        &lt;description xmlns:ns1='http://predic8.com/material/1/'&gt;bar&lt;/description&gt;
        &lt;price xmlns:ns1='http://predic8.com/common/1/'&gt;
           &lt;amount xmlns:ns1='http://predic8.com/common/1/'&gt;00.00&lt;/amount&gt;
           &lt;currency xmlns:ns1='http://predic8.com/common/1/'&gt;USD&lt;/currency&gt;
        &lt;/price&gt;
        &lt;id xmlns:ns1='http://predic8.com/material/1/'&gt;1&lt;/id&gt;
     &lt;/article&gt;
  &lt;/ns1:create&gt;
  </code></pre>
  
  <p>What would be the best (most efficient) way to flatten this into a set of xpath expressions.
  Note also: I want to ignore any namespace and attribute information. (If needed, this could also be done as a pre-processing step).</p>
  
  <p>So I want get as output:</p>
  
  <pre><code>/create/article/name
  /create/article/description
  /create/article/price/amount
  /create/article/price/currency
  /create/article/id
  </code></pre>
  
  <p>I’m implementing in Java.</p>
  
  <p><strong>EDIT:</strong>
  PS, I might also need this to work in the case that there is no data at the text node, so for example, this following should generate the same output as the above:</p>
  
  <pre><code>&lt;ns1:create xmlns:ns1='http://predic8.com/wsdl/material/ArticleService/1/'&gt;
    &lt;article xmlns:ns1='http://predic8.com/material/1/'&gt;
      &lt;name /&gt;
      &lt;description /&gt;
      &lt;price xmlns:ns1='http://predic8.com/common/1/'&gt;
        &lt;amount /&gt;
        &lt;currency xmlns:ns1='http://predic8.com/common/1/'&gt;&lt;/currency&gt;
      &lt;/price&gt;
      &lt;id xmlns:ns1='http://predic8.com/material/1/'&gt;&lt;/id&gt;
    &lt;/article&gt;
  &lt;/ns1:create&gt;
  </code></pre>