public class XMLParser extends DefaultHandler
| Constructor and Description |
|---|
XMLParser()
Creates a new instance of XMLParser.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] chars,
int start,
int length)
Handle character data.
|
void |
endElement(String namespaceURI,
String localName,
String qName)
Handle the end of an element.
|
XMLParseResult |
parse(File xmlFile)
Parses the passed XML file.
|
XMLParseResult |
parse(InputSource source)
Parses the passed XML input source.
|
XMLParseResult |
parse(String xml)
Parses the passed XML string.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes attrs)
Handle the start of an element.
|
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningpublic XMLParseResult parse(String xml) throws IOException, SAXException
xml - XML string to parse.XMLParseResult representing the XML data.IOException - If something goes wrong reading the XML input data.SAXException - If something goes wrong creating a parser or parsing the XML.public XMLParseResult parse(File xmlFile) throws IOException, SAXException
xmlFile - XML file to parse.XMLParseResult representing the XML data.IOException - If something goes wrong reading the XML input data.SAXException - If something goes wrong creating a parser or parsing the XML.public XMLParseResult parse(InputSource source) throws IOException, SAXException
source - XML input source to parse.XMLParseResult representing the XML data.IOException - If something goes wrong reading the XML input data.SAXException - If something goes wrong creating a parser or parsing the XML.public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException
startElement in interface ContentHandlerstartElement in class DefaultHandlernamespaceURI - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace
processing is not being performed.localName - The local name (without prefix), or the empty string if Namespace processing is not being
performed.qName - The qualified name (with prefix), or the empty string if qualified names are not available.attrs - The attributes attached to the element. If there are no attributes, this will be empty.SAXException - If something goes wrong processing the start of an element.public void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class DefaultHandlernamespaceURI - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace
processing is not being performed.localName - The local name (without prefix), or the empty string if Namespace processing is not being
performed.qName - The qualified name (with prefix), or the empty string if qualified names are not available.SAXException - If something goes wrong processing the end of an element.public void characters(char[] chars,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class DefaultHandlerchars - The characters from the XML document.start - The start position in the array.length - The number of characters to read from the array.SAXException - If something goes wrong processing the characters.Copyright (c) 2014-2021 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries