Package org.scijava.util
Class XML
- java.lang.Object
-
- org.scijava.util.XML
-
-
Constructor Summary
Constructors Constructor Description XML(File file)Parses XML from the given file.XML(InputStream in)Parses XML from the given input stream.XML(String s)Parses XML from the given string.XML(String path, Document doc)Creates an XML object for an existing document.XML(URL url)Parses XML from the given URL.XML(Document doc)Creates an XML object for an existing document.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcdata(String expression)Obtains the CDATA identified by the given XPath expression.static Stringcdata(Element el, String child)Gets the CData beneath the given element's specified child.static Stringcdata(Node item)Gets the CData beneath the given node.ArrayList<Element>elements(String expression)Obtains the elements identified by the given XPath expression.static ArrayList<Element>elements(Element el, String child)Gets the given element's specified child elements.static ArrayList<Element>elements(NodeList nodes)Gets the element nodes from the given node list.DocumentgetDocument()Gets the XML's DOM representation.StringgetPath()Gets the path to the XML document, or null if none.protected static DocumentloadXML(InputStream in)Loads an XML document from the given input stream.protected static DocumentloadXML(String s)Loads an XML document from the given input stream.StringtoString()NodeListxpath(String expression)Obtains the nodes identified by the given XPath expression.
-
-
-
Constructor Detail
-
XML
public XML(File file) throws ParserConfigurationException, SAXException, IOException
Parses XML from the given file.
-
XML
public XML(URL url) throws ParserConfigurationException, SAXException, IOException
Parses XML from the given URL.
-
XML
public XML(InputStream in) throws ParserConfigurationException, SAXException, IOException
Parses XML from the given input stream.
-
XML
public XML(String s) throws ParserConfigurationException, SAXException, IOException
Parses XML from the given string.
-
XML
public XML(Document doc)
Creates an XML object for an existing document.
-
-
Method Detail
-
getPath
public String getPath()
Gets the path to the XML document, or null if none.
-
getDocument
public Document getDocument()
Gets the XML's DOM representation.
-
cdata
public String cdata(String expression)
Obtains the CDATA identified by the given XPath expression.
-
elements
public ArrayList<Element> elements(String expression)
Obtains the elements identified by the given XPath expression.
-
xpath
public NodeList xpath(String expression)
Obtains the nodes identified by the given XPath expression.
-
cdata
public static String cdata(Element el, String child)
Gets the CData beneath the given element's specified child.
-
elements
public static ArrayList<Element> elements(NodeList nodes)
Gets the element nodes from the given node list.
-
elements
public static ArrayList<Element> elements(Element el, String child)
Gets the given element's specified child elements.
-
loadXML
protected static Document loadXML(InputStream in) throws ParserConfigurationException, SAXException, IOException
Loads an XML document from the given input stream.
-
loadXML
protected static Document loadXML(String s) throws ParserConfigurationException, SAXException, IOException
Loads an XML document from the given input stream.
-
-