title: Cannot replace node value
body: <p>I have a SOAP message as as string which looks like:</p>
  
  <pre><code> String testMsg = "&lt;soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"&gt;&lt;soap:Header&gt;Some Header stuff&lt;/soap:Header&gt;&lt;soap:Body&gt;Some Body Stuff&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;";
  </code></pre>
  
  <p>Then it goes to XPath but can't find a node (came as null) to set text value</p>
  
  <pre><code>    Document doc = convertStringToDocument(testMsg);
      XPath xpath = XPathFactory.newInstance().newXPath();
  
      String expression = "//soap:Envelope/soap:Body";
      Node node = (Node) xpath.evaluate(expression, doc, XPathConstants.NODE);
  
      // Set the node content
      node.setTextContent("Body was removed");
  </code></pre>
  
  <p>I try to convert it to XML document using method below</p>
  
  <pre><code>private static Document convertStringToDocument(String xmlStr) {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setNamespaceAware(true);
  
      try
      {
          DocumentBuilder builder = factory.newDocumentBuilder();
          InputSource is = new InputSource(new StringReader(xmlStr));
          Document doc = builder.parse(is);
  
          return doc;
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>Any thoughts?</p>