title: Using Jackson to add XML attributes to manually-built node-tree
body: <p>I'm trying to set up code to create a node tree using <code>Jackson</code> which can then be used to write either <code>JSON</code> or <code>XML</code>. I've created the node tree manually like so:</p>
  
  <pre><code>XmlMapper nodeMapper = new XmlMapper();
  
  ObjectNode rootNode = nodeMapper.createObjectNode();
  ObjectNode currentNode = rootNode.putObject("Examples");
  currentNode.put("Puppy", TRUE)
             .put("Apple", 2)
             .put("Jet", "Li");
  currentNode = rootNode.putObject("Single");
  currentNode.put("One", 1);
  
  String writePath = "C:/users/itsameamario/Documents/basicXMLtest.xml";
  nodeMapper.writeValue(new File(writePath), rootNode);
  </code></pre>
  
  <p>My XML output is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;ObjectNode&gt;
      &lt;Examples&gt;
          &lt;Puppy&gt;true&lt;/Puppy&gt;
          &lt;Apple&gt;2&lt;/Apple&gt;
          &lt;Jet&gt;Li&lt;/Jet&gt;
      &lt;/Examples&gt;
      &lt;Single&gt;
          &lt;One&gt;1&lt;/One&gt;
      &lt;/Single&gt;
  &lt;/ObjectNode&gt;
  </code></pre>
  
  <p>However for some parts of the XML I would like to add an attribute to one of the nodes like so:</p>
  
  <pre><code>&lt;Examples overlyComplicated="yes"&gt;
  &lt;!--...--&gt;
  &lt;/Examples&gt;
  </code></pre>
  
  <p>All the examples I've found that include attributes are applied to a pre-existing class. I have been unable to find a method to add attributes to a manually-built node-tree as above. Is it doable using <code>Jackson</code>?</p>