Table of Contents

Class SimpleXmlParser

Namespace
iTextSharp.text.xml.simpleparser
Assembly
iTextSharp.LGPLv2.Core.dll

A simple XML and HTML parser. This parser is, like the SAX parser, an event based parser, but with much less functionality. The parser can: It recognizes the encoding used It recognizes all the elements' start tags and end tags It lists attributes, where attribute values can be enclosed in single or double quotes It recognizes the <[CDATA[ ... ]]> construct It recognizes the standard entities: &amp;, &lt;, &gt;, &quot;, and &apos;, as well as numeric entities It maps lines ending in \r\n and \r to \n on input, in accordance with the XML Specification, Section 2.11 The code is based on http://www.javaworld.com/javaworld/javatips/javatip128/ with some extra code from XERCES to recognize the encoding.

public sealed class SimpleXmlParser
Inheritance
SimpleXmlParser
Inherited Members

Methods

EscapeXml(string, bool)

Escapes a string with the appropriated XML codes.

public static string EscapeXml(string s, bool onlyAscii)

Parameters

s string

the string to be escaped

onlyAscii bool

codes above 127 will always be escaped with &#nn; if true

Returns

string

the escaped string

Parse(ISimpleXmlDocHandler, Stream)

Parses the XML document firing the events to the handler. @throws IOException on error

public static void Parse(ISimpleXmlDocHandler doc, Stream inp)

Parameters

doc ISimpleXmlDocHandler

the document handler

inp Stream

the document. The encoding is deduced from the stream. The stream is not closed

Parse(ISimpleXmlDocHandler, TextReader)

public static void Parse(ISimpleXmlDocHandler doc, TextReader r)

Parameters

doc ISimpleXmlDocHandler
r TextReader

Parse(ISimpleXmlDocHandler, ISimpleXmlDocHandlerComment, TextReader, bool)

Parses the XML document firing the events to the handler. @throws IOException on error

public static void Parse(ISimpleXmlDocHandler doc, ISimpleXmlDocHandlerComment comment, TextReader r, bool html)

Parameters

doc ISimpleXmlDocHandler

the document handler

comment ISimpleXmlDocHandlerComment
r TextReader

the document. The encoding is already resolved. The reader is not closed

html bool