title: xPath expression create or modify a node
body: <p>I would like to understand how to create or modify a node in a simple XML file.</p>
  
  <p>the following is the XML file:</p>
  
  <pre><code>&lt;?xml version = "1.0"?&gt;
      &lt;myRootNode&gt;
          &lt;myNode a="P" b="Q" c="R"&gt;
              &lt;subNode id= "1"&gt;
                  &lt;x&gt;more text&lt;/x&gt;
                  &lt;y&gt;some more&lt;/y&gt;
              &lt;/subNode&gt;
              &lt;subNode id="2"&gt;
                  &lt;x&gt;blah&lt;/x&gt;
                  &lt;y&gt;&lt;blah blah&lt;/y&gt;
              &lt;/subNode&gt;
          &lt;/myNode&gt;
          &lt;myNode a="S" b="T" c="U"&gt;
              &lt;subNode id= "1"&gt;
                  &lt;x&gt;some more text&lt;/x&gt;
                  &lt;y&gt;even more&lt;/y&gt;
              &lt;/subNode&gt;
              &lt;subNode id="2"&gt;
                  &lt;x&gt;abcdefg&lt;/x&gt;
                  &lt;y&gt;hijklmno&lt;/y&gt;
              &lt;/subNode&gt;
          &lt;/myNode&gt;
      &lt;/myRootNode&gt;
  </code></pre>
  
  <p>I would like to know how to edit a node's inner text. for eg: Edit the inner text of the node achieved by evaluating the expression:</p>
  
  <pre><code>/myRootNode/myNode[@a='P' and @b='Q' and @c='R']/subNode[@id='1']/x
  </code></pre>
  
  <p>I would also like to know how can I use pure xPath to insert a node:</p>
  
  <pre><code>&lt;subNode id="3"&gt;
      &lt;x&gt;pqrst&lt;/x&gt;
      &lt;y&gt;uvxyz&lt;/y&gt;
  &lt;/subNode&gt;
  </code></pre>
  
  <p>after the node achieved by evaluating the expression:</p>
  
  <pre><code>/myRootNode/myNode[@a='P' and @b='Q' and @c='R']/subNode[@id="2"]
  </code></pre>
  
  <p>If possible, please provide Java code. Thank you.</p>