title: Read an XML file using node.js xpath xmldom
body: <p>I'm attempting to select certain parts of an XML document using the node packages XPATH &amp; XMLDOM, but I am getting nothing through for the element values.  At a guess it's probably my XPATH definition, but to be honest I've no idea.</p>
  
  <p>The top of my XML looks like the following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="define2-0-0.xsl"?&gt;
  &lt;ODM
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns="http://www.cdisc.org/ns/odm/v1.3"
  xmlns:def="http://www.cdisc.org/ns/def/v2.0"
  ODMVersion="1.3.2"
  FileType="Snapshot"
  FileOID="StudyNum.ADaM-IG.1.0"
  CreationDateTime="2018-02-08T09:40:51"&gt;
  &lt;Study OID="StudyNum.ADaM-IG.1.0"&gt;
  &lt;GlobalVariables&gt;
  &lt;StudyName&gt;StudyNum&lt;/StudyName&gt;
  &lt;StudyDescription&gt;Study Description&lt;/StudyDescription&gt;
  &lt;ProtocolName&gt;StudyName_PRCL_StudyNum&lt;/ProtocolName&gt;
  &lt;/GlobalVariables&gt;
  &lt;MetaDataVersion OID="MDV.StudyNum.ADaM-IG.1.0" Name="Study StudyNum Data Definitions"
  Description="Awful Syndrome"
  def:DefineVersion="2.0.0"
  </code></pre>
  
  <p>and my code so far looks like the following:</p>
  
  <pre><code>var xpath = require('xpath'),
      dom   = require('xmldom').DOMParser,
      fs = require('fs');
  
  var xml = fs.readFileSync('./Define/define.xml', 'utf8').toString();
  var select = xpath.useNamespaces({"xlink":"http://www.w3.org/1999/xlink", "ODM":"http://www.cdisc.org/ns/odm/v1.3", "def":"http://www.cdisc.org/ns/def/v2.0"});
  var doc = new dom().parseFromString(xml)
  
  console.log("test 1 : " + select('//ODM:Study/@OID', doc)[0].nodeValue);
  console.log("test 2 : " + select('//ODM:Study/GlobalVariables/StudyName/', doc)[0].nodeValue);
  </code></pre>
  
  <p>The first test generates the expected result, but I just get an error with 'test 2'.  Am I missing the obvious?</p>
  
  <p>Thanks.</p>