title: I am using docx4j for reading .docx files and I need to get the paragraph of a document and replace strings
body: <p>I am using docx4j for reading and parsing .docx files but when I iterate through paragraphs it is reading in one pass not all of the paragraph.  Below is a sample of the code I am using.</p>
  
  <pre><code>private void replaceAcrAndDef(String acrName, String acrParensName, String oldDef, String newDef){
      String XPATH_TO_SELECT_TEXT_NODES = "//w:t";
      List&lt;Object&gt; paragraphs = template.getMainDocumentPart().getJAXBNodesViaXPath(XPATH_TO_SELECT_TEXT_NODES, true);
      for (Object obj : paragraphs){
          Text text = (Text) ((JAXBElement)obj).getValue();
          String textValue = text.getValue();
          System.out.println(textValue);
   }
  </code></pre>
  
  <p>During one pass of the for loop above this will read as the first paragraph - </p>
  
  <p>"Team has a deep understanding of the  requirements by having direct MDA experience for the Mission, Test and Administrative and General Services networks and systems. The benefits to re a low risk, responsive Team with an established understanding of Mission, Processes and Priorities. Our use of an integrated based"</p>
  
  <p>But it is missing the last parts of the paragraph.  Which will come out in the consecutive passes.  What am I doing wrong here.</p>
  
  <p>The entire contents of the paragraph are :</p>
  
  <p>Team has a deep understanding of the requirements by having direct MDA experience for the  Mission, Test and Administrative and General Services networks and systems. The benefits to are a low risk, responsive Team with an established understanding of Mission, Processes and Priorities. Our use of an integrated Information Technology  based Role-Based Administration (RBA) approach works in synergy with associate contractors, existing processes and the addition of our complementary processes. </p>
  
  <p>I do not know if there is a way to get the entire paragraph or not but if there is that would be great as I need to do String replacement on a paragraph by paragraph basis.</p>