Table of Contents

Class XmlProcessorCreator

Namespace
iText.Kernel.Utils
Assembly
itext.kernel.dll

Utility class for creating XML processors.

public static class XmlProcessorCreator
Inheritance
XmlProcessorCreator
Inherited Members

Methods

CreateSafeXmlReader(Stream)

Creates the instance of System.Xml.XmlReader. The default implementation is configured to prevent possible XML attacks (see DefaultSafeXmlParserFactory). But you can use SetXmlParserFactory(IXmlParserFactory) to set your specific factory for creating xml parsers.

public static XmlReader CreateSafeXmlReader(Stream stream)

Parameters

stream Stream

the stream that contains the XML data.

Returns

XmlReader

an object that is used to read the XML data in the stream.

CreateSafeXmlReader(Stream, XmlParserContext)

Creates the instance of System.Xml.XmlReader. The default implementation is configured to prevent possible XML attacks (see DefaultSafeXmlParserFactory). But you can use SetXmlParserFactory(IXmlParserFactory) to set your specific factory for creating xml parsers.

public static XmlReader CreateSafeXmlReader(Stream stream, XmlParserContext inputContext)

Parameters

stream Stream

the stream that contains the XML data.

inputContext XmlParserContext

the context information required to parse the XML fragment.

Returns

XmlReader

an object that is used to read the XML data in the stream.

CreateSafeXmlReader(TextReader)

Creates the instance of System.Xml.XmlReader. The default implementation is configured to prevent possible XML attacks (see DefaultSafeXmlParserFactory). But you can use SetXmlParserFactory(IXmlParserFactory) to set your specific factory for creating xml parsers.

public static XmlReader CreateSafeXmlReader(TextReader textReader)

Parameters

textReader TextReader

the text reader from which to read the XML data.

Returns

XmlReader

an object that is used to read the XML data in the stream.

SetXmlParserFactory(IXmlParserFactory)

Specifies an IXmlParserFactory implementation that will be used to create the xml parsers in the XmlProcessorCreator. Pass DefaultSafeXmlParserFactory to use default safe factory that should prevent XML attacks like XML bombs and XXE attacks. This will definitely throw an exception if any DTD object is present in the XML. If you need the special XML parser creating, you can declare your own IXmlParserFactory implementation and pass it to this method.

public static void SetXmlParserFactory(IXmlParserFactory factory)

Parameters

factory IXmlParserFactory

factory to be used to create xml parsers. If the passed factory is null, the DefaultSafeXmlParserFactory will be used