title: XML and tree, line get out the tree
body: <p>I want to transform my XML file into a tree in Java with the framework Vaadin. But with one line it get out the tree and I don't understand why, to understand I made a little one XML:</p>
  
  <pre><code>&lt;overlay&gt;
      &lt;type&gt;bgp&lt;/type&gt;
      &lt;bgp&gt;
          &lt;bgp-asn&gt;12&lt;/bgp-asn&gt;
      &lt;/bgp&gt;
  &lt;/overlay&gt;
  &lt;overlay-routing&gt;
      &lt;type&gt;test&lt;/type&gt;
      &lt;b&gt;
          &lt;bgp-as&gt;11&lt;/bgp-as&gt;
      &lt;/b&gt;
  &lt;/overlay-routing&gt;
  </code></pre>
  
  <p>And here the result :
  <a href="https://i.stack.imgur.com/s4xpl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s4xpl.png" alt="tree"></a></p>
  
  <p>So you can see I just change the name of my line in XML and it works, but with the "bgp-asn" it doesn't work and I really don't understand. It is a key work for XML ? Or something like that ?
  I can put my code :</p>
  
  <pre><code>private Component test(){
          VerticalLayout ver = new VerticalLayout();
          ver.setSizeFull();
          TextArea text = new TextArea();
          Button send = new Button("send");
          tre = new Tree();
          tre.setSizeFull();
  
          send.addClickListener(new ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                  if(text.isEmpty()){
                      return;
                  }
                  Node node = getData(text.getValue());
                  loadTree(tre, null, node);
              }
          });
  
  private Document getData(String data){
          data = "&lt;capsule&gt;" + data;
          data = data + "&lt;/capsule&gt;";
          try {
              if(data == null){
                  return null;
              } else {
                  try{
                      builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                  } catch (ParserConfigurationException e){
                      throw new RuntimeException("cannot create a data source", e);
                  }
                  return builder.parse(new ByteArrayInputStream(data.trim().getBytes("UTF-8")));
              }
              //return data == null ? null : builder.parse(new ByteArrayInputStream(data.trim().getBytes("UTF-8")));
          } catch (SAXException | IOException e) {
              throw new RuntimeException("cannot load data from content", e);
          }
      }
  </code></pre>
  
  <p>and loadtree:</p>
  
  <pre><code>private void loadTree(Tree tree, Object parentID, Node element){
  
          if(tree == null || element == null){
              return;
          }
          final String itemID = (element.getNodeType() == Node.TEXT_NODE ? element.getNodeValue() : element.getNodeName()).trim();
  
          if(itemID.length() == 0){
              return;
          }
          tree.addItem(itemID);
  
          if(parentID != null){
              tree.setParent(itemID, parentID);
          }
          NodeList children = element.getChildNodes();
          System.out.println(parentID);
          for(int i = 0, n = children.getLength(); i &lt; n; i++){
  
              loadTree(tree, itemID, children.item(i));
          }
          if(children.getLength() &gt; 0){
              tree.expandItem(itemID);
          } else{
              tree.setChildrenAllowed(itemID, false);
          }
      }
  </code></pre>
  
  <p>If you know what is wrong, it will be awesome ! 
  Thank you ! </p>