public boolean isCompactEmpty () { return compactEmpty && !hasNodes (); }
public boolean isCompact (Element e) { return (!e.hasNodes () && e.isCompactEmpty ()); }
public Element clearChildren () { if (!hasNodes ()) return this; for (Iterator<Node> iter = getNodes ().iterator (); iter.hasNext (); ) { Node n = iter.next (); if (isElement (n)) iter.remove (); } return this; }
public boolean hasChildren () { if (!hasNodes ()) return false; for (Node node: getNodes ()) { if (isElement (node)) return true; } return false; }
public Element getChild (int index) { int count = 0; if (hasNodes ()) { for (Node n: getNodes ()) { if (isElement (n)) { if (index == count) return (Element)n; count ++; } } } throw new IndexOutOfBoundsException ("Cannot return child "+index +", node has only "+count+(count == 1 ? " child" : " children")); }
public Element clearText () { if (!hasNodes ()) return this; for (Iterator<Node> iter = getNodes ().iterator (); iter.hasNext ();) { Node n = iter.next (); if (isText (n)) { iter.remove (); } else if (isElement (n)) { ((Element)n).clearText (); } } return this; }
public String getText () { if (!hasNodes ()) return ""; StringBuilder buffer = new StringBuilder (); for (Node n: getNodes ()) { if (isText (n)) buffer.append (((Text)n).getText ()); else if (isElement (n)) buffer.append (((Element)n).getText ()); else if (n.getType () == Type.ENTITY) buffer.append (((Entity)n).getText ()); } return buffer.toString (); }
if (!hasNodes ()) return null;
public Node next () { Node n = currentNode ().getNode (getCursor ()); incCursor (); if (XMLUtils.isElement (n)) { Element e = (Element)n; if (e.hasNodes ()) push (e); } return n; }
if (e.hasNodes () && !XMLUtils.isElement (e.getNode (0)))