Beispiel #1
0
 /**
  * Converts the XML to Tree * is used to represent an empty string # is used for an empty list
  * These escape charectors will get removed from the file and will not effect the content of the
  * Tree.
  *
  * @param node
  * @return
  */
 private static Tree xmlToTree(Node node) {
   NodeList nl = node.getChildNodes();
   Node firstChild = nl.item(0);
   if (nl.getLength() > 0 && firstChild instanceof Text) {
     String text = ((Text) firstChild).getWholeText();
     if (text.charAt(0) == STRING_ESCAPE) {
       return new Tree(text.substring(1));
     } else if (text.charAt(0) == TREE_ESCAPE) {
       return new Tree();
     } else {
       return new Tree(text);
     }
   }
   Tree t = new Tree();
   for (int i = 0; i < nl.getLength(); i++)
     t.add(new Tree.Entry(nl.item(i).getNodeName(), xmlToTree(nl.item(i))));
   return t;
 }