org.scijava.util
Class XML

java.lang.Object
  extended by org.scijava.util.XML
Direct Known Subclasses:
POM

public class XML
extends Object

Helper class for working with XML documents.

Author:
Curtis Rueden

Constructor Summary
XML(Document doc)
          Creates an XML object for an existing document.
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.
 
Method Summary
 String cdata(String expression)
          Obtains the CDATA identified by the given XPath expression.
 Document getDocument()
          Gets the XML's DOM representation.
 String getPath()
          Gets the path to the XML document, or null if none.
protected static Document loadXML(InputStream in)
          Loads an XML document from the given input stream.
protected static Document loadXML(String s)
          Loads an XML document from the given input stream.
 String toString()
           
 NodeList xpath(String expression)
          Obtains the nodes identified by the given XPath expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XML

public XML(File file)
    throws ParserConfigurationException,
           SAXException,
           IOException
Parses XML from the given file.

Throws:
ParserConfigurationException
SAXException
IOException

XML

public XML(URL url)
    throws ParserConfigurationException,
           SAXException,
           IOException
Parses XML from the given URL.

Throws:
ParserConfigurationException
SAXException
IOException

XML

public XML(InputStream in)
    throws ParserConfigurationException,
           SAXException,
           IOException
Parses XML from the given input stream.

Throws:
ParserConfigurationException
SAXException
IOException

XML

public XML(String s)
    throws ParserConfigurationException,
           SAXException,
           IOException
Parses XML from the given string.

Throws:
ParserConfigurationException
SAXException
IOException

XML

public XML(Document doc)
Creates an XML object for an existing document.


XML

public XML(String path,
           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.


xpath

public NodeList xpath(String expression)
Obtains the nodes identified by the given XPath expression.


toString

public String toString()
Overrides:
toString in class Object

loadXML

protected static Document loadXML(InputStream in)
                           throws ParserConfigurationException,
                                  SAXException,
                                  IOException
Loads an XML document from the given input stream.

Throws:
ParserConfigurationException
SAXException
IOException

loadXML

protected static Document loadXML(String s)
                           throws ParserConfigurationException,
                                  SAXException,
                                  IOException
Loads an XML document from the given input stream.

Throws:
ParserConfigurationException
SAXException
IOException


Copyright © 2009–2015 SciJava. All rights reserved.