title: Xpath.evaluate() method does not return any value on JAVA
body: <p>I have one XML example file like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!--Sample XML file generated by XMLSpy v2011 rel. 2 (x64) (http://www.altova.com)--&gt;
  &lt;Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.05"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.05 file://BE-FILE01/tverschu$/SR%20(Standards%20Release)/SR2013/ISO/Payments%20Initiation/SR2013_MX_Schemas_PaymentsInitiation/pain.001.001.05.xsd"&gt;
  &lt;CstmrCdtTrfInitn&gt;
      &lt;GrpHdr&gt;
          &lt;MsgId&gt;ABC/120928/CCT001&lt;/MsgId&gt;
          &lt;CreDtTm&gt;2012-09-28T14:07:00&lt;/CreDtTm&gt;
          &lt;NbOfTxs&gt;3&lt;/NbOfTxs&gt;
          &lt;CtrlSum&gt;11500000&lt;/CtrlSum&gt;
          &lt;InitgPty&gt;
              &lt;Nm&gt;ABC Corporation&lt;/Nm&gt;
              &lt;PstlAdr&gt;
                  &lt;StrtNm&gt;Times Square&lt;/StrtNm&gt;
                  &lt;BldgNb&gt;7&lt;/BldgNb&gt;
                  &lt;PstCd&gt;NY 10036&lt;/PstCd&gt;
                  &lt;TwnNm&gt;New York&lt;/TwnNm&gt;
                  &lt;Ctry&gt;US&lt;/Ctry&gt;
              &lt;/PstlAdr&gt;
          &lt;/InitgPty&gt;
      &lt;/GrpHdr&gt;
      &lt;PmtInf&gt;
          &lt;PmtInfId&gt;ABC/086&lt;/PmtInfId&gt;
          &lt;PmtMtd&gt;TRF&lt;/PmtMtd&gt;
          &lt;BtchBookg&gt;false&lt;/BtchBookg&gt;
          &lt;ReqdExctnDt&gt;2012-09-29&lt;/ReqdExctnDt&gt;
          &lt;Dbtr&gt;
              &lt;Nm&gt;ABC Corporation&lt;/Nm&gt;
              &lt;PstlAdr&gt;
                  &lt;StrtNm&gt;Times Square&lt;/StrtNm&gt;
                  &lt;BldgNb&gt;7&lt;/BldgNb&gt;
                  &lt;PstCd&gt;NY 10036&lt;/PstCd&gt;
                  &lt;TwnNm&gt;New York&lt;/TwnNm&gt;
                  &lt;Ctry&gt;US&lt;/Ctry&gt;
              &lt;/PstlAdr&gt;
          &lt;/Dbtr&gt;
          &lt;DbtrAcct&gt;
              &lt;Id&gt;
                  &lt;Othr&gt;
                      &lt;Id&gt;00125574999&lt;/Id&gt;
                  &lt;/Othr&gt;
              &lt;/Id&gt;
          &lt;/DbtrAcct&gt;
          &lt;DbtrAgt&gt;
              &lt;FinInstnId&gt;
                  &lt;BICFI&gt;BBBBUS33&lt;/BICFI&gt;
              &lt;/FinInstnId&gt;
          &lt;/DbtrAgt&gt;
          &lt;CdtTrfTxInf&gt;
              &lt;PmtId&gt;
                  &lt;InstrId&gt;ABC/120928/CCT001/01&lt;/InstrId&gt;
                  &lt;EndToEndId&gt;ABC/4562/2012-09-08&lt;/EndToEndId&gt;
              &lt;/PmtId&gt;
              &lt;Amt&gt;
                  &lt;InstdAmt Ccy="JPY"&gt;10000000&lt;/InstdAmt&gt;
              &lt;/Amt&gt;
              &lt;ChrgBr&gt;SHAR&lt;/ChrgBr&gt;
              &lt;CdtrAgt&gt;
                  &lt;FinInstnId&gt;
                      &lt;BICFI&gt;AAAAGB2L&lt;/BICFI&gt;
                  &lt;/FinInstnId&gt;
              &lt;/CdtrAgt&gt;
              &lt;Cdtr&gt;
                  &lt;Nm&gt;DEF Electronics&lt;/Nm&gt;
                  &lt;PstlAdr&gt;
                      &lt;AdrLine&gt;Corn Exchange 5th Floor&lt;/AdrLine&gt;
                      &lt;AdrLine&gt;Mark Lane 55&lt;/AdrLine&gt;
                      &lt;AdrLine&gt;EC3R7NE London&lt;/AdrLine&gt;
                      &lt;AdrLine&gt;GB&lt;/AdrLine&gt;
                  &lt;/PstlAdr&gt;
              &lt;/Cdtr&gt;
              &lt;CdtrAcct&gt;
                  &lt;Id&gt;
                      &lt;Othr&gt;
                          &lt;Id&gt;23683707994125&lt;/Id&gt;
                      &lt;/Othr&gt;
                  &lt;/Id&gt;
              &lt;/CdtrAcct&gt;
              &lt;Purp&gt;
                  &lt;Cd&gt;GDDS&lt;/Cd&gt;
              &lt;/Purp&gt;
              &lt;RmtInf&gt;
                  &lt;Strd&gt;
                      &lt;RfrdDocInf&gt;
                          &lt;Tp&gt;
                              &lt;CdOrPrtry&gt;
                                  &lt;Cd&gt;CINV&lt;/Cd&gt;
                              &lt;/CdOrPrtry&gt;
                          &lt;/Tp&gt;
                          &lt;Nb&gt;4562&lt;/Nb&gt;
                          &lt;RltdDt&gt;2012-09-08&lt;/RltdDt&gt;
                      &lt;/RfrdDocInf&gt;
                  &lt;/Strd&gt;
              &lt;/RmtInf&gt;
          &lt;/CdtTrfTxInf&gt;
          &lt;CdtTrfTxInf&gt;
              &lt;PmtId&gt;
                  &lt;InstrId&gt;ABC/120928/CCT001/2&lt;/InstrId&gt;
                  &lt;EndToEndId&gt;ABC/ABC-13679/2012-09-15&lt;/EndToEndId&gt;
              &lt;/PmtId&gt;
              &lt;Amt&gt;
                  &lt;InstdAmt Ccy="EUR"&gt;500000&lt;/InstdAmt&gt;
              &lt;/Amt&gt;
              &lt;ChrgBr&gt;CRED&lt;/ChrgBr&gt;
              &lt;CdtrAgt&gt;
                  &lt;FinInstnId&gt;
                      &lt;BICFI&gt;DDDDBEBB&lt;/BICFI&gt;
                  &lt;/FinInstnId&gt;
              &lt;/CdtrAgt&gt;
              &lt;Cdtr&gt;
                  &lt;Nm&gt;GHI Semiconductors&lt;/Nm&gt;
                  &lt;PstlAdr&gt;
                      &lt;StrtNm&gt;Avenue Brugmann&lt;/StrtNm&gt;
                      &lt;BldgNb&gt;415&lt;/BldgNb&gt;
                      &lt;PstCd&gt;1180&lt;/PstCd&gt;
                      &lt;TwnNm&gt;Brussels&lt;/TwnNm&gt;
                      &lt;Ctry&gt;BE&lt;/Ctry&gt;
                  &lt;/PstlAdr&gt;
              &lt;/Cdtr&gt;
              &lt;CdtrAcct&gt;
                  &lt;Id&gt;
                      &lt;IBAN&gt;BE30001216371411&lt;/IBAN&gt;
                  &lt;/Id&gt;
              &lt;/CdtrAcct&gt;
              &lt;InstrForCdtrAgt&gt;
                  &lt;Cd&gt;PHOB&lt;/Cd&gt;
                  &lt;InstrInf&gt;+32/2/2222222&lt;/InstrInf&gt;
              &lt;/InstrForCdtrAgt&gt;
              &lt;Purp&gt;
                  &lt;Cd&gt;GDDS&lt;/Cd&gt;
              &lt;/Purp&gt;
              &lt;RmtInf&gt;
                  &lt;Strd&gt;
                      &lt;RfrdDocInf&gt;
                          &lt;Tp&gt;
                              &lt;CdOrPrtry&gt;
                                  &lt;Cd&gt;CINV&lt;/Cd&gt;
                              &lt;/CdOrPrtry&gt;
                          &lt;/Tp&gt;
                          &lt;Nb&gt;ABC-13679&lt;/Nb&gt;
                          &lt;RltdDt&gt;2012-09-15&lt;/RltdDt&gt;
                      &lt;/RfrdDocInf&gt;
                  &lt;/Strd&gt;
              &lt;/RmtInf&gt;
          &lt;/CdtTrfTxInf&gt;
          &lt;CdtTrfTxInf&gt;
              &lt;PmtId&gt;
                  &lt;InstrId&gt;ABC/120928/CCT001/3&lt;/InstrId&gt;
                  &lt;EndToEndId&gt;ABC/987-AC/2012-09-27&lt;/EndToEndId&gt;
              &lt;/PmtId&gt;
              &lt;Amt&gt;
                  &lt;InstdAmt Ccy="USD"&gt;1000000&lt;/InstdAmt&gt;
              &lt;/Amt&gt;
              &lt;ChrgBr&gt;SHAR&lt;/ChrgBr&gt;
              &lt;CdtrAgt&gt;
                  &lt;FinInstnId&gt;
                      &lt;BICFI&gt;BBBBUS66&lt;/BICFI&gt;
                  &lt;/FinInstnId&gt;
              &lt;/CdtrAgt&gt;
              &lt;Cdtr&gt;
                  &lt;Nm&gt;ABC Corporation&lt;/Nm&gt;
                  &lt;PstlAdr&gt;
                      &lt;Dept&gt;Treasury department&lt;/Dept&gt;
                      &lt;StrtNm&gt;Bush Street&lt;/StrtNm&gt;
                      &lt;BldgNb&gt;13&lt;/BldgNb&gt;
                      &lt;PstCd&gt;CA 94108&lt;/PstCd&gt;
                      &lt;TwnNm&gt;San Francisco&lt;/TwnNm&gt;
                      &lt;Ctry&gt;US&lt;/Ctry&gt;
                  &lt;/PstlAdr&gt;
              &lt;/Cdtr&gt;
              &lt;CdtrAcct&gt;
                  &lt;Id&gt;
                      &lt;Othr&gt;
                          &lt;Id&gt;4895623&lt;/Id&gt;
                      &lt;/Othr&gt;
                  &lt;/Id&gt;
              &lt;/CdtrAcct&gt;
              &lt;Purp&gt;
                  &lt;Cd&gt;INTC&lt;/Cd&gt;
              &lt;/Purp&gt;
              &lt;RmtInf&gt;
                  &lt;Strd&gt;
                      &lt;RfrdDocInf&gt;
                          &lt;Tp&gt;
                              &lt;CdOrPrtry&gt;
                                  &lt;Cd&gt;CINV&lt;/Cd&gt;
                              &lt;/CdOrPrtry&gt;
                          &lt;/Tp&gt;
                          &lt;Nb&gt;987-AC&lt;/Nb&gt;
                          &lt;RltdDt&gt;2012-09-27&lt;/RltdDt&gt;
                      &lt;/RfrdDocInf&gt;
                  &lt;/Strd&gt;
              &lt;/RmtInf&gt;
          &lt;/CdtTrfTxInf&gt;
      &lt;/PmtInf&gt;
  &lt;/CstmrCdtTrfInitn&gt;
  &lt;/Document&gt;
  </code></pre>
  
  <p>I want to retrieve xmlns attribute value from Document tag. For this I'm using xpath's evaluate method:</p>
  
  <pre><code>            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
          InputStream inputStream = new FileInputStream(new File("Business sample 1 pain.001.xml"));
          org.w3c.dom.Document doc = documentBuilderFactory.newDocumentBuilder().parse(inputStream);
          StringWriter stw = new StringWriter();
          Transformer serializer = TransformerFactory.newInstance().newTransformer();
          serializer.transform(new DOMSource(doc), new StreamResult(stw));
  
          XPathFactory factory = XPathFactory.newInstance();
          XPath xpath = factory.newXPath();
  
  
          String xml = stw.toString();
  
          InputSource xmlsource = new InputSource(new StringReader(xml));
  
          String value = xpath.evaluate(
              "Document/attribute::xmlns", xmlsource);
  
          System.out.println(value);
  </code></pre>
  
  <p>This code returns value as "". </p>
  
  <p>I had tried changing:</p>
  
  <pre><code>String value = xpath.evaluate("Document/attribute::xmlns", xmlsource);
  </code></pre>
  
  <p>for:</p>
  
  <pre><code>String value = xpath.evaluate("Document/CstmrCdtTrfInitn/GrpHdr/MsgId", xmlsource);
  </code></pre>
  
  <p>for testing and I got the same return "".</p>
  
  <p>What I'm doing wrong?</p>
  
  <p>The return I need is <code>pain.001.001.05</code> but if I get all the string <code>urn:iso:std:iso:20022:tech:xsd:pain.001.001.05</code> it is useful for me too.</p>
  
  <p>Thank you in advance.</p>