Class XmlTools


  • public class XmlTools
    extends Object
    XML toolkit.
    Author:
    Martin Scharm
    • Constructor Detail

      • XmlTools

        public XmlTools()
    • Method Detail

      • getBuilder

        public static org.jdom2.input.SAXBuilder getBuilder()
        Returns:
        the sax builder
      • readDocument

        public static org.jdom2.Document readDocument​(File file)
                                               throws IOException,
                                                      org.jdom2.JDOMException
        Reads an XML document from File.
        Parameters:
        file - the document to read
        Returns:
        the document
        Throws:
        IOException - Signals that an I/O exception has occurred.
        org.jdom2.JDOMException - the jDOM exception
      • readDocument

        public static org.jdom2.Document readDocument​(URL url)
                                               throws IOException,
                                                      URISyntaxException,
                                                      org.jdom2.JDOMException
        Read an XML document from web.
        Parameters:
        url - the url to the document
        Returns:
        the document
        Throws:
        IOException - Signals that an I/O exception has occurred.
        URISyntaxException - the uRI syntax exception
        org.jdom2.JDOMException - the jDOM exception
      • readDocument

        public static org.jdom2.Document readDocument​(InputStream is)
                                               throws IOException,
                                                      org.jdom2.JDOMException
        Reads an XML document from File.
        Parameters:
        is - the stream containing the document
        Returns:
        the document
        Throws:
        IOException - Signals that an I/O exception has occurred.
        org.jdom2.JDOMException - the jDOM exception
      • readDocument

        public static org.jdom2.Document readDocument​(String doc)
                                               throws IOException,
                                                      org.jdom2.JDOMException
        Read an XML document from String.
        Parameters:
        doc - the string containing the XML document
        Returns:
        the document
        Throws:
        IOException - Signals that an I/O exception has occurred.
        org.jdom2.JDOMException - the jDOM exception
      • printDocument

        public static String printDocument​(org.jdom2.Document doc)
        Prints a document.
        Parameters:
        doc - the document
        Returns:
        the string
      • prettyPrintDocument

        public static String prettyPrintDocument​(org.jdom2.Document doc)
        Pretty prints a document.
        Parameters:
        doc - the document
        Returns:
        the output stream