Normally, applications will use Xml, LooseXml, Html, or LooseHtml.
This is a thin layer on top of a SAX parser. The key concept necessary to understand this parser is Element Handler. Element handlers are type-specific parsers. Each handler instance contains an instance of the Java type corresponding to the XML type it parses. At any given time, one handler is active, and zero or more handlers are kept on the stack. This corresponds directly to the set of currently opened XML tags.
To use this parser, one must define an {@link XmlParser.ElementHandler} type (usually one per XML schema type),specify the root element handler, and pass a reader to the {@link #parse(Reader,com.google.gdata.util.XmlParser.ElementHandler,String,String)} method.
@see XmlParser.ElementHandler
Alternatively, you can use the standard SAX interfaces with the SAXDriver
class as your entry point.
@author Copyright (c) 1997, 1998 by Microstar Software Ltd.
@author Written by David Megginson <dmeggins@microstar.com>
@version 1.1
@see XmlHandler
@see HandlerBase
@see SAXDriver
def xml = '<root><one a1="uno!"/><two>Some text!</two></root>' def rootNode = new XmlParser().parseText(xml) assert rootNode.name() == 'root' assert rootNode.one[0].@a1 == 'uno!' assert rootNode.two.text() == 'Some text!' rootNode.children().each { assert it.name() in ['one','two'] }@author James Strachan @author Paul King @version $Revision: 19635 $
String xml = ...; String namespaces = "xmlns:default=\"http://code.google.com/p/totoe\" " + "xmlns:foo=\"http://code.google.com/p/totoe/foo\" " + "xmlns:bar=\"http://code.google.com/p/totoe/bar\" " + "xmlns:bttf=\"http://en.wikipedia.org/wiki/Back_to_the_Future\""; Document document = new XmlParser().parse(xml, namespaces);@author $Author$ @version $Date$ $Revision: 623$
XMLParser
parses the XML Jelly format. The SAXParser and XMLReader portions of this code come from Digester.
By default, the parser is created as a validating parser. This can be changed by setting the "org.mortbay.xml.XmlParser.NotValidating" system property to true. @version $Id: XmlParser.java,v 1.21 2005/10/25 07:53:22 gregwilkins Exp $ @author Greg Wilkins (gregw)
By default, the parser is created as a validating parser only if xerces is present. This can be configured by setting the "org.eclipse.jetty.xml.XmlParser.Validating" system property.
By default, the parser is created as a validating parser only if xerces is present. This can be configured by setting the "org.mortbay.xml.XmlParser.Validating" system property. @author Greg Wilkins (gregw)
By default, the parser is created as a validating parser. This can be changed by setting the "org.openqa.jetty.xml.XmlParser.NotValidating" system property to true. @version $Id: XmlParser.java,v 1.21 2005/10/25 07:53:22 gregwilkins Exp $ @author Greg Wilkins (gregw)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|