public Node parse(Node xml, String s) { s = s.trim(); int i; T context = createContext(); xml.name("document"); Node child = new Node(); while ((i = context.parse(s.toCharArray(), child) + 1) < s.length()) { if (child.name == null && child.children.size() == 1) child = child.children.get(0); xml.add(child); child = new Node(); context = createContext(); context.i = i; } if (child.name == null && child.children.size() == 1) child = child.children.get(0); xml.add(child); return xml; }