org.eclipse.jetty.xml

## Class XmlParser

- java.lang.Object
- - org.eclipse.jetty.xml.XmlParser

    public class XmlParser
    extends Object

XML Parser wrapper. This class wraps any standard JAXP1.1 parser with convieniant error and entity handlers and a mini dom-like document tree.

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.

### Nested Class Summary

Nested Classes
`static class` `XmlParser.Attribute` XML Attribute.
`static class` `XmlParser.Node` XML Node.

### Constructor Summary

Constructors
Constructor and Description
`XmlParser()` Construct
`XmlParser(boolean validating)` Constructor.

### Method Summary

Methods
`void` `addContentHandler(String trigger, ContentHandler observer)` Add a ContentHandler.
`String` `getDTD()`
`String` `getXpath()`
`XmlParser.Node` `parse(File file)` Parse File.
`XmlParser.Node` `parse(InputSource source)`
`XmlParser.Node` `parse(InputStream in)` Parse InputStream.
`XmlParser.Node` `parse(String url)` Parse String URL.
`void` `redirectEntity(String name, URL entity)`
`void` `setValidating(boolean validating)`
`void` `setXpath(String xpath)` Set an XPath A very simple subset of xpath is supported to select a partial tree.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### XmlParser

    public XmlParser()

Construct

#### XmlParser

    public XmlParser(boolean validating)

Constructor.

### Method Detail

#### setValidating

    public void setValidating(boolean validating)

#### redirectEntity

    public void redirectEntity(String name,
                      URL entity)

Parameters:
  `name` -
  `entity` -

#### getXpath

    public String getXpath()

Returns:
  Returns the xpath.

#### setXpath

    public void setXpath(String xpath)

Set an XPath A very simple subset of xpath is supported to select a partial tree. Currently only path like "/node1/nodeA | /node1/nodeB" are supported.

Parameters:
  `xpath` - The xpath to set.

#### getDTD

    public String getDTD()

#### addContentHandler

    public void addContentHandler(String trigger,
                         ContentHandler observer)

Add a ContentHandler. Add an additional _content handler that is triggered on a tag name. SAX events are passed to the ContentHandler provided from a matching start element to the corresponding end element. Only a single _content handler can be registered against each tag.

Parameters:
  `trigger` - Tag local or q name.
  `observer` - SAX ContentHandler

#### parse

    public XmlParser.Node parse(InputSource source)
                         throws IOException,
                                SAXException

Throws:
  `IOException`
  `SAXException`

#### parse

    public XmlParser.Node parse(String url)
                         throws IOException,
                                SAXException

Parse String URL.

Throws:
  `IOException`
  `SAXException`

#### parse

    public XmlParser.Node parse(File file)
                         throws IOException,
                                SAXException

Parse File.

Throws:
  `IOException`
  `SAXException`

#### parse

    public XmlParser.Node parse(InputStream in)
                         throws IOException,
                                SAXException

Parse InputStream.

Throws:
  `IOException`
  `SAXException`