title: How to retrieve xpath from pom.xml with libxmljs
body: <p>My issue has to do with namespaces.</p>
  
  <p>I am trying to retrieve the value of the  element from a maven pom xml. My libxml-js code is as follows:</p>
  
  <pre><code>var fs = require('fs');
  var libxml = require('libxmljs');
  
  fs.readFile('pom.xml', 'utf8', function (err,data) {
     var doc = libxml.parseXmlString(data);
     var root = doc.root();
     var version = root.get("parent/version");
     console.log(version.text());
  }
  </code></pre>
  
  <p>If I use pom.xml <strong>without</strong> the namespace declarations as follows, it finds the element and prints "2.0.1-SNAPSHOT" correctly.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;artifactId&gt;acme-main&lt;/artifactId&gt;
          &lt;groupId&gt;com.acme&lt;/groupId&gt;
          &lt;version&gt;2.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>However, as soon as I put back the original (valid and required) namespace declarations as follows, I get an exception because it's not able to find that element.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;artifactId&gt;acme-main&lt;/artifactId&gt;
          &lt;groupId&gt;com.acme&lt;/groupId&gt;
          &lt;version&gt;2.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>My question is, how do I retrieve the /project/parent/version value from the default namespace while retaining the namespace declarations in my pom?</p>
  
  <p>Thanks!</p>
  
  <p>PS: I am open to using other node libraries than libxml-js if there are any suggestions.</p>