title: XPath to select value of an attribute using namespace
body: <p>Hi I'm having a problem getting the value of an attribute in an xml file using namespaces. </p>
  
  <pre><code>&lt;module name="ietf-inet-types"
          xmlns="urn:ietf:params:xml:ns:yang:yin:1"
          xmlns:inet="urn:ietf:params:xml:ns:yang:ietf-inet-types"&gt;
    &lt;namespace uri="urn:ietf:params:xml:ns:yang:ietf-inet-types"/&gt;
    &lt;prefix value="inet"/&gt;
  &lt;/module&gt;
  </code></pre>
  
  <p>I want to get "inet" as the result of my xpath. I used this link <a href="https://stackoverflow.com/questions/5518096/xpath-to-select-value-of-sibling-attribute-with-namespace">Xpath to select value of sibling attribute with namespace</a> as a reference and came up with:</p>
  
  <pre><code>$xml-&gt;xpath('/n:module/n:prefix/@n:value');
  </code></pre>
  
  <p>where n is the namespace prefix. However I'm getting an empty array as a result, what exactly am I doing wrong here?</p>
  
  <p>Update:
  Heres some of the php code I'm using to retrieve the value. </p>
  
  <pre><code>//gets the namespace from the model
  $xpathNamespace = getXpathNamespace($domxml);
  $xml = simplexml_load_string($domxml-&gt;saveXML());
  $xml-&gt;registerXPathNamespace("n", $xpathNamespace);
  print_r($xml-&gt;xpath('/n:module/n:prefix/@n:value'));
  </code></pre>