CMDXMLParser Class Reference

#include <gmxmlparser.h>

Link against: xmlparser.lib

class CMDXMLParser : public CActive

Inherits from

Detailed Description

Creates a DOM structure from a given XML file.

The parsing operation is asynchronous and is initiated by a call to ParseFile(). On completion, the created DOM document can be retrieved through DetachXMLDoc().

Note the following ownership rules for the DOM document:

1. calling DetachXMLDoc() transfers ownership of the document to the client

2. if the parser is asked to parse a new file while it still owns an existing DOM document, it will delete the old document.

Member Enumeration Documentation

Enum TMDXMLParserInputCharWidth

Defines input stream character widths.

EnumeratorValueDescription
EAscii0x01
EUnicode0x02

Constructor & Destructor Documentation

~CMDXMLParser ( )

IMPORT_C~CMDXMLParser()

Destructor.

Member Function Documentation

DetachXMLDoc ( )

IMPORT_C CMDXMLDocument *DetachXMLDoc()

Gets the created DOM.

This should be called after the conclusion of the parser process.

Note that the function sets the internal variable pointing to the document to NULL, so this function can only be called once per file parse. The caller takes ownership of the document, and must delete it when its use is complete.

Return Value
The created DOM

EntityConverter ( )

CMDXMLEntityConverter *EntityConverter()

Gets the entity converter.

Return Value
The entity converter

Error ( )

IMPORT_C TIntError()const

Gets the last error found by the parser.

Return Value
Error code

ErrorSeverity ( )

IMPORT_C TXMLErrorCodeSeverityErrorSeverity()const

Get the severity of the most severe error found.

Return Value
the maximum error severity

NewL ( MMDXMLParserObserver * )

IMPORT_C CMDXMLParser *NewL(MMDXMLParserObserver *aParserObserver)[static]

Allocates and constructs a new XML parser, specifying a DTD.

Parameters
aParserObserverXML parser observer
Return Value
New XML parser
Leave Codes
KErrNoMemoryOut of memory

NewL ( MMDXMLParserObserver *, MXMLDtd * )

IMPORT_C CMDXMLParser *NewL(MMDXMLParserObserver *aParserObserver,
MXMLDtd *aDtdRepresentation
)[static]

Allocates and constructs a new XML parser, specifying a DTD.

Parameters
aParserObserverXML parser observer
aDtdRepresentationDTD validator
Return Value
New XML parser
Leave Codes
KErrNoMemoryOut of memory

NewLC ( MMDXMLParserObserver * )

IMPORT_C CMDXMLParser *NewLC(MMDXMLParserObserver *aParserObserver)[static]

Allocates and constructs a new XML parser, leaving the object on the cleanup stack.

Parameters
aParserObserverXML parser observer
Return Value
New XML parser
Leave Codes
KErrNoMemoryOut of memory

NewLC ( MMDXMLParserObserver *, MXMLDtd * )

IMPORT_C CMDXMLParser *NewLC(MMDXMLParserObserver *aParserObserver,
MXMLDtd *aDtdRepresentation
)[static]

Allocates and constructs a new XML parser, leaving the object on the cleanup stack.

Parameters
aParserObserverXML parser observer
aDtdRepresentationDTD validator
Return Value
New XML parser
Leave Codes
KErrNoMemoryOut of memory

ParseFile ( RFs, const TDesC & )

IMPORT_C TIntParseFile(RFsaRFs,
const TDesC &aFileToParse
)

Parses a specified XML file into a DOM object tree.

Parameters
aRFsFile server session
aFileToParseThe file name to parse
Return Value
KErrNone if success or a file read error code

ParseFile ( RFile & )

IMPORT_C TIntParseFile(RFile &aFileHandleToParse)

Parses a specified XML file into a DOM object tree.

Parses a specified XML file into a DOM object tree using an open file handle. The parser takes ownership of the open file handle and will close handle when completed.

Parameters
aFileHandleToParseAn open file handle for the file to parse. Ownership of the file handle is passed.
Return Value
KErrNone if successful.

ParseSource ( MMDXMLParserDataProvider * )

voidParseSource(MMDXMLParserDataProvider *aSource)[inline]

Parses a specified XML Data Source into a DOM object tree. Use ParseSourceL() function in preference to ParseSource()

Parameters
aSourceMMDXMLParserDataProvider pointer

ParseSourceL ( MMDXMLParserDataProvider * )

IMPORT_C voidParseSourceL(MMDXMLParserDataProvider *aSource)

Parses a specified XML Data Source into a DOM object tree.

Parameters
aSourceMMDXMLParserDataProvider pointer

SetEntityConverter ( CMDXMLEntityConverter * )

IMPORT_C voidSetEntityConverter(CMDXMLEntityConverter *aEntityConverter)

Sets the entity converter to be used for parsing. and take ownership of the passed entity converter

Parameters
aEntityConverterthe entity converter to be used.

SetSourceCharacterWidth ( TMDXMLParserInputCharWidth )

IMPORT_C voidSetSourceCharacterWidth(TMDXMLParserInputCharWidthaWidth)

Sets the input stream character width.

Parameters
aWidthCharacter width for incoming stream. Possible values are EAscii and EUnicode (representing Ascii/UTF8 and Unicode respectively).

SetStoreInvalid ( TBool )

IMPORT_C voidSetStoreInvalid(TBoolaStoreInvalid)

Controls whether invalid elements and attributes are added to the DOM.

Parameters
aStoreInvalidETrue if invalid content should be stored, EFalse otherwise.

SetWhiteSpaceHandlingMode ( TBool )

IMPORT_C voidSetWhiteSpaceHandlingMode(TBoolaPreserve)

Controls whether whitespaces are handled by XML parser or by client.

Parameters
aPreserveETrue if all whitespaces should be preserved (handled by client), EFalse otherwise.