# Class: com.pnfsoftware.jeb.util.encoding.xml.XmlParser

A thread\-safe, limited, simple, lenient, fast, read\-only \(except for user\-data on nodes\) XML parser. It can be used as a back\-up when the JDK implementation \(typically, Apache Xerces\) fails on documents deviating from the XML specifications. 

 Features and limitations: 
 
- XML version must be 1.x, encoding must be UTF\-8.
-  
- All unicode chars are accepted as long as there is no parsing ambiguity.
-  
- Multiple root elements are allowed.
-  
- Android\-style backslash escapes in attribute values can be supported \( [details](#setHandleBackslashAxmlStyle(boolean))\).
-  
- This parser returns XML documents implementing the read\-only parts of the standard `org.w3c.dom` API \(refer to the `X...` classes in this package\).
-  
- The following XML node types are NOT supported: `DocumentFragment`, `Entity`, `EntityReference`, `Notation`, `ProcessingInstruction`.
-  
- Calls to unsupported methods will raise [UnsupportedOperationException](UnsupportedOperationException).
-  
- Allow unclosed tags \(like the famous html <br\>\)
-  
- Allow unquoted attribute values
-  
- The resulting Document tree is thread\-safe, including for setUserData calls
-

## Constructor: XmlParser


## Method: isAllowMismatchedTags
- return type: `boolean`

Description: 
return: the default is false

## Method: isAllowNoXmlDeclaration
- return type: `boolean`

Description: 
return: the default is false

## Method: isAllowUnclosedTags
- return type: `boolean`

Description: 
return: the default is false

## Method: isAssignParentNodes
- return type: `boolean`

Description: 
return: the default is false

## Method: isHandleBackslashAxmlStyle
- return type: `boolean`

Description: 
return: the default is false

## Method: isSortAttributes
- return type: `boolean`

Description: 
return: the default is false

## Method: parse
- parameter: `str`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.util.encoding.xml.XDocument`

Description: Parse the provided XML string and return an XML [Document](Document) object. This method will throw if an error occurs.
parameter: str: XML string \(the encoding attribute is disregarded\)
return: a document object, never null \(the method throws on error\)

## Method: parse
- parameter: `bytes`, type: `byte[]`
- return type: `com.pnfsoftware.jeb.util.encoding.xml.XDocument`

Description: Parse the provided XML data and return an XML [Document](Document) object. This method will throw if an error occurs.
parameter: str: XML data
return: a document object, never null \(the method throws on error\)

## Method: setAllowMismatchedTags
- parameter: `allowMismatchedTags`, type: `boolean`

Description: 
parameter: allowMismatchedTags: if true, the parser will match the tags case\-insensitively

## Method: setAllowNoXmlDeclaration
- parameter: `allowNoXmlDeclaration`, type: `boolean`

Description: 
parameter: allowNoXmlDeclaration: if true, the parser will process even if no xml declaration is            found \(<?xml...\)

## Method: setAllowUnclosedTags
- parameter: `allowUnclosedTags`, type: `boolean`

Description: 
parameter: allowUnclosedTags: if true, the parser will consider unclosed tags as part of            [XText](XText)

## Method: setAssignParentNodes
- parameter: `assignParentNodes`, type: `boolean`

Description: 
parameter: assignParentNodes: if true, the internal parent and/or owner fields are set, allowing            the use of methods like [Node#getParentNode()](Node#getParentNode()),            [Node#getOwnerDocument()](Node#getOwnerDocument()), [Attr#getOwnerElement()](Attr#getOwnerElement()), etc.

## Method: setHandleBackslashAxmlStyle
- parameter: `handleBackslashAxmlStyle`, type: `boolean`

Description: 
parameter: handleBackslashAxmlStyle: If true, `\n` and `\t` escapes are allowed in            attribute values. Other escapes \(`\x`\) will result in the character "x". If            false, The normal XML behavior applies: \\ is a regular character, meaning \\x is            literally "\\x".

## Method: setSortAttributes
- parameter: `sortAttributes`, type: `boolean`

Description: 
parameter: sortAttributes: if true, the element attributes are sorted by name, alphabetically; if            false, the original order is maintained \(note: Xerces does alphasort\)

