|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.util.XmlParser
public class XmlParser
A helper class for parsing XML into a tree of Node instances for a simple way of processing XML. This parser does not preserve the XML InfoSet - if thats what you need try using W3C DOM, dom4j, JDOM, XOM etc. This parser ignores comments and processing instructions and converts the XML into a Node for each element in the XML with attributes and child Nodes and Strings. This simple model is sufficient for most simple use cases of processing XML.
Constructor Summary | |
---|---|
XmlParser()
|
|
XmlParser(boolean validating,
boolean namespaceAware)
|
|
XmlParser(SAXParser parser)
|
|
XmlParser(XMLReader reader)
|
Method Summary | |
---|---|
protected void |
addTextToNode()
|
void |
characters(char[] buffer,
int start,
int length)
|
void |
endDocument()
|
void |
endElement(String namespaceURI,
String localName,
String qName)
|
void |
endPrefixMapping(String prefix)
|
Locator |
getDocumentLocator()
|
protected Object |
getElementName(String namespaceURI,
String localName,
String qName)
|
protected XMLReader |
getXMLReader()
|
void |
ignorableWhitespace(char[] buffer,
int start,
int len)
|
Node |
parse(File file)
Parses the content of the given file as XML turning it into a tree of Nodes |
Node |
parse(InputSource input)
Parse the content of the specified input source into a tree of Nodes. |
Node |
parse(InputStream input)
Parse the content of the specified input stream into a tree of Nodes. |
Node |
parse(Reader in)
Parse the content of the specified reader into a tree of Nodes. |
Node |
parse(String uri)
Parse the content of the specified URI into a tree of Nodes |
Node |
parseText(String text)
A helper method to parse the given text as XML |
void |
processingInstruction(String target,
String data)
|
void |
setDocumentLocator(Locator locator)
|
void |
skippedEntity(String name)
|
void |
startDocument()
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes list)
|
void |
startPrefixMapping(String prefix,
String namespaceURI)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlParser() throws ParserConfigurationException, SAXException
ParserConfigurationException
SAXException
public XmlParser(boolean validating, boolean namespaceAware) throws ParserConfigurationException, SAXException
ParserConfigurationException
SAXException
public XmlParser(XMLReader reader)
public XmlParser(SAXParser parser) throws SAXException
SAXException
Method Detail |
---|
public Node parse(File file) throws IOException, SAXException
IOException
SAXException
public Node parse(InputSource input) throws IOException, SAXException
IOException
SAXException
public Node parse(InputStream input) throws IOException, SAXException
IOException
SAXException
public Node parse(Reader in) throws IOException, SAXException
IOException
SAXException
public Node parse(String uri) throws IOException, SAXException
IOException
SAXException
public Node parseText(String text) throws IOException, SAXException
text
-
IOException
SAXException
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
SAXException
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
SAXException
public void startElement(String namespaceURI, String localName, String qName, Attributes list) throws SAXException
startElement
in interface ContentHandler
SAXException
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
SAXException
public void characters(char[] buffer, int start, int length) throws SAXException
characters
in interface ContentHandler
SAXException
public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException
startPrefixMapping
in interface ContentHandler
SAXException
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
SAXException
public void ignorableWhitespace(char[] buffer, int start, int len) throws SAXException
ignorableWhitespace
in interface ContentHandler
SAXException
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
SAXException
public Locator getDocumentLocator()
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
public void skippedEntity(String name) throws SAXException
skippedEntity
in interface ContentHandler
SAXException
protected XMLReader getXMLReader()
protected void addTextToNode()
protected Object getElementName(String namespaceURI, String localName, String qName) throws SAXException
SAXException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |