title: read, replace placeholders and write a word file with docx4j
body: <p>I have a Word File look like this:
  <img src="https://i.stack.imgur.com/xhiXs.jpg" alt=""></p>
  
  <p>You don't need to understand the content, just take a look to my placeholders <code>&lt;env&gt;</code> and <code>&lt;applikationsabkürzung&gt;</code>. There are 10 pages with these placeholders and now I should replace them with other content. The black and yellow box are company pictures which I won't share.</p>
  
  <p>Now I started to read the whole <a href="http://htmlpreview.github.io/?https://github.com/plutext/docx4j/blob/master/docs/Docx4j_GettingStarted.html" rel="nofollow noreferrer">docx4j doc</a> and generate after some time the following code:</p>
  
  <pre><code>public void manipulateWord(String path, String env, String appl) {
      try {
          WordprocessingMLPackage wpml = WordprocessingMLPackage.load(new File(path));
  
          MainDocumentPart mdp = wpml.getMainDocumentPart();
  
          List&lt;Object&gt; content = mdp.getContent();
  
          // Include all Strings to replace
          HashMap&lt;String, String&gt; mappings = new HashMap&lt;String, String&gt;();
          mappings.put("&lt;env&gt;", env);
          mappings.put("&lt;applikationsabkürzung&gt;", appl);
  
          for (Object object : content) {
              Text textElement = (Text) object;
              String textToReplace = textElement.getValue();
              if (mappings.keySet().contains(textToReplace)) {
                  textElement.setValue(mappings.get(textToReplace));
              }
          }
  
          wpml.save(new File("C:\\Users\\kristina\\Desktop\\outputfile.docx"));
  
      } catch (Docx4JException e) {
          LOG.error(e);
      }
  </code></pre>
  
  <p>Some explanaition:</p>
  
  <ul>
  <li><code>String path</code> is the path of the file in the picture above</li>
  <li><code>String env</code> is the value which should replace <code>&lt;env&gt;</code></li>
  <li><code>String appl</code> is the value which should replace <code>&lt;applikationsabkürzung&gt;</code></li>
  </ul>
  
  <p>But when I run the method, nothing happen, my console just print just some infos. If they're important, i'll edit the post, but i don't think so. </p>
  
  <p>So where is my fault? Would it work like that? I'm shortly before to despair...</p>