Search in sources :

Example 1 with XmlDocument

use of org.xmlpull.infoset.XmlDocument in project airavata by apache.

the class XMLUtil method loadXML.

/**
 * @param file
 * @return The XmlElement in the document.
 * @throws IOException
 */
public static org.xmlpull.infoset.XmlElement loadXML(InputStream stream) throws IOException {
    String xmlText = IOUtil.readToString(stream);
    XmlDocument document = BUILDER.parseString(xmlText);
    return document.getDocumentElement();
}
Also used : XmlDocument(org.xmlpull.infoset.XmlDocument)

Example 2 with XmlDocument

use of org.xmlpull.infoset.XmlDocument in project airavata by apache.

the class XMLUtil method stringToXmlElement.

/**
 * Parses a specified string and returns the XmlElement (XPP5).
 *
 * @param string
 * @return The XmlElement (XPP5) parsed.
 */
public static org.xmlpull.infoset.XmlElement stringToXmlElement(String string) {
    XmlDocument document = BUILDER.parseString(string);
    org.xmlpull.infoset.XmlElement element = document.getDocumentElement();
    return element;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement) XmlDocument(org.xmlpull.infoset.XmlDocument)

Example 3 with XmlDocument

use of org.xmlpull.infoset.XmlDocument in project airavata by apache.

the class XMLUtil method saveXML.

/**
 * Saves a specified XmlElement to a specified file.
 *
 * @param element
 * @param file
 * @throws IOException
 */
public static void saveXML(org.xmlpull.infoset.XmlElement element, File file) throws IOException {
    XmlDocument document = BUILDER.newDocument();
    document.setDocumentElement(element);
    String xmlText = BUILDER.serializeToStringPretty(document);
    IOUtil.writeToFile(xmlText, file);
}
Also used : XmlDocument(org.xmlpull.infoset.XmlDocument)

Aggregations

XmlDocument (org.xmlpull.infoset.XmlDocument)3 XmlElement (org.xmlpull.infoset.XmlElement)1