public class XMLUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
XMLUtil.TagFormat
Tag format options.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
formatAttributes(Node node)
Returns formatted attributes of the node.
|
static String |
formatNodeName(Node node,
XMLUtil.TagFormat format)
Returns the formatted name for the node.
|
static DocumentBuilder |
newDocumentBuilder(boolean nsAware)
Returns a new document builder instance.
|
static Document |
parseXMLFromList(Iterable<String> xml)
Parses XML from a list of strings.
|
static Document |
parseXMLFromLocation(String filePath)
Parses XML from a file.
|
static Document |
parseXMLFromSource(InputSource source)
Parses XML from an input source.
|
static Document |
parseXMLFromStream(InputStream stream)
Parses XML from an input stream.
|
static Document |
parseXMLFromString(String xml)
Parses XML from a string.
|
static String |
toString(Document doc)
Converts an XML document to a formatted XML string.
|
static String |
toString(Document doc,
int indent)
Converts an XML document to a formatted XML string.
|
public static DocumentBuilder newDocumentBuilder(boolean nsAware) throws ParserConfigurationException
nsAware - If true, builder will be namespace aware.ParserConfigurationException - Parser configuration error.public static Document parseXMLFromSource(InputSource source) throws Exception
source - An input source containing valid XML.Exception - Unspecified exception.public static Document parseXMLFromString(String xml) throws Exception
xml - String containing valid XML.Exception - Unspecified exception.public static Document parseXMLFromList(Iterable<String> xml) throws Exception
xml - String iterable containing valid XML.Exception - Unspecified exception.public static Document parseXMLFromLocation(String filePath) throws Exception
filePath - Full path to a file containing valid XML.Exception - Unspecified exception.public static Document parseXMLFromStream(InputStream stream) throws Exception
stream - Input stream containing valid XML.Exception - Unspecified exception.public static String toString(Document doc)
doc - The document to format.public static String toString(Document doc, int indent)
doc - The document to format.indent - Number of characters to indent.public static String formatNodeName(Node node, XMLUtil.TagFormat format)
node - Node to format.format - Desired format (opening tag, closing tag, empty tag, or both).Copyright © 2018 Regenstrief Center for Biomedical Informatics. All rights reserved.