Package org.apache.pivot.xml
Class XML
- java.lang.Object
-
- org.apache.pivot.xml.XML
-
public final class XML extends java.lang.ObjectContains utility methods for working with XML structures.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ElementgetElement(Element root, java.lang.String path)Returns the element matching a given path.static List<Element>getElements(Element root, java.lang.String path, java.lang.String name)Returns the sub-elements of a descendant ofrootwhose tag names match the given name.static java.lang.StringgetText(Element root, java.lang.String path)Returns the text content of a descendant ofroot.
-
-
-
Method Detail
-
getElement
public static Element getElement(Element root, java.lang.String path)
Returns the element matching a given path.- Parameters:
root- The element from which to begin the search.path- A path of the form:tag[n]/tag[n]/...
The bracketed index values are optional and refer to the nth occurrence of the given tag name within its parent element. If omitted, the path refers to the first occurrence of the named element (i.e. the element at index 0).- Returns:
- The matching element, or
nullif no such element exists.
-
getElements
public static List<Element> getElements(Element root, java.lang.String path, java.lang.String name)
Returns the sub-elements of a descendant ofrootwhose tag names match the given name.- Parameters:
root- The element from which to begin the search.path- The path to the descendant, relative toroot.name- The tag name to match.- Returns:
- The matching elements, or
nullif no such descendant exists. - See Also:
getElement(Element, String),Element.getElements(String)
-
getText
public static java.lang.String getText(Element root, java.lang.String path)
Returns the text content of a descendant ofroot.- Parameters:
root- The element from which to begin the search.path- The path to the descendant, relative toroot.- Returns:
- The text of the descedant, or
nullif no such descendant exists. - See Also:
getElement(Element, String),Element.getText()
-
-