public final class XMLUtil extends Object
Modifier and Type | Field and Description |
---|---|
protected static DocumentBuilder |
docBuilder
Document builder for creating DOMs.
|
Modifier and Type | Method and Description |
---|---|
static Element |
createChild(Element el,
String name)
Appends a child element with the given name to the specified DOM element.
|
static Document |
createDocument(String rootName)
Creates a new DOM.
|
static Text |
createText(Element el,
String info)
Appends a text node with the given information to the specified DOM
element.
|
static Element[] |
getChildren(Element el,
String name)
Retrieves the given DOM element's child elements with the specified name.
|
static Element |
getFirstChild(Element el,
String name)
Retrieves the given DOM element's first child element with the specified
name.
|
static String |
getText(Element el)
Gets the text information associated with the given DOM element.
|
static Document |
parseXML(File file)
Parses a DOM from the given XML file on disk.
|
static Document |
parseXML(InputStream is)
Parses a DOM from the given XML input stream.
|
static Document |
parseXML(String xml)
Parses a DOM from the given XML string.
|
static String |
writeXML(Document doc)
Writes the given DOM to a string.
|
static void |
writeXML(File file,
Document doc)
Writes the given DOM to the specified file on disk.
|
static void |
writeXML(OutputStream os,
Document doc)
Writes the given DOM to the specified output stream.
|
protected static DocumentBuilder docBuilder
public static Document parseXML(InputStream is)
public static void writeXML(File file, Document doc)
public static String writeXML(Document doc)
public static void writeXML(OutputStream os, Document doc)
public static Element createChild(Element el, String name)
public static Text createText(Element el, String info)
public static Element getFirstChild(Element el, String name)
public static Element[] getChildren(Element el, String name)
Copyright © 2015–2022 SciJava. All rights reserved.