|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectezvcard.util.XmlUtils
public class XmlUtils
Generic XML utility methods.
Method Summary | |
---|---|
static Document |
createDocument()
Creates a new XML document. |
static Element |
getFirstChildElement(Element parent)
Gets the first child element of an element. |
static Element |
getRootElement(Document parent)
Gets the root element of a document. |
static Document |
toDocument(InputStream in)
Parses an XML document from an input stream. |
static Document |
toDocument(Reader reader)
Parses an XML document from a reader. |
static Document |
toDocument(String xml)
Parses an XML string into a DOM. |
static List<Element> |
toElementList(NodeList nodeList)
Gets all the elements out of a NodeList . |
static String |
toString(Node node)
Converts an XML node to a string. |
static String |
toString(Node node,
Map<String,String> outputProperties)
Converts an XML node to a string. |
static void |
toWriter(Node node,
Writer writer)
Writes an XML node to a writer. |
static void |
toWriter(Node node,
Writer writer,
Map<String,String> outputProperties)
Writes an XML node to a writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Document createDocument()
public static Document toDocument(String xml) throws SAXException
xml
- the XML string
SAXException
- if the string is not valid XMLpublic static Document toDocument(InputStream in) throws SAXException, IOException
in
- the input stream
SAXException
- if the XML is not valid
IOException
- if there is a problem reading from the input streampublic static Document toDocument(Reader reader) throws SAXException, IOException
Parses an XML document from a reader.
Note that use of this method is discouraged. It ignores the character
encoding that is defined within the XML document itself, and should only
be used if the encoding is undefined or if the encoding needs to be
ignored for whatever reason. The toDocument(InputStream)
method
should be used instead, since it takes the XML document's character
encoding into account when parsing.
reader
- the reader
SAXException
- if the XML is not valid
IOException
- if there is a problem reading from the readerpublic static String toString(Node node)
node
- the XML node
public static String toString(Node node, Map<String,String> outputProperties)
node
- the XML nodeoutputProperties
- the output properties
public static void toWriter(Node node, Writer writer) throws TransformerException
node
- the XML nodewriter
- the writer
TransformerException
- if there's a problem writing to the writerpublic static void toWriter(Node node, Writer writer, Map<String,String> outputProperties) throws TransformerException
node
- the XML nodewriter
- the writeroutputProperties
- the output properties
TransformerException
- if there's a problem writing to the writerpublic static List<Element> toElementList(NodeList nodeList)
NodeList
.
nodeList
- the node list
public static Element getRootElement(Document parent)
parent
- the document
public static Element getFirstChildElement(Element parent)
parent
- the parent element
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |