SophiaFramework UNIVERSE 5.3 |
There are two kinds of XML parsers. One is named "DOM" parser, the another is named "SAX" parser.
The DOM parser expands XML document onto memory as the DOM tree. With the DOM parser, it is very easy to operate an XML document, but usually a lot of memory is needed.
The SAX parser is a set of APIs that read XML document sequentially from the beginning and processes it in an event driven style. It needs less memory and is faster than the DOM parser, but there is no update function for XML documents such as adding, deleting a node etc.
SophiaFramework provides you with SFXXMLDOMParser as the DOM parser, SFXXMLSAXParser as the SAX parser.
The basic functions of SFXXMLDOMParser and SFXXMLSAXParser used by SophiaFramework are as follows:
Table 19.6. Parse
Function Name of the SFXXMLDOMParser class | Function Name of the SFXXMLSAXParser class | Description |
---|---|---|
SFXXMLDOMParser::Parse | SFXXMLSAXParser::Parse | Function to read and parse XML document. |
Set a parser attribute
Parser attributes are set by using the Set function.
Table 19.7. Function of Setting Parser Attributes
caution | |
---|---|
In these SetXXXXXXXXX functions, the attribute value is set to "false" by default except for the SFXXMLDOMParser::SetIgnoreAnnotations / SFXXMLSAXParser::SetIgnoreAnnotations function. |
Get a parser attribute
Parser attributes can be obtained by using Get functions.
Table 19.8. Function of Getting Parser Attributes
Function Name of the SFXXMLDOMParser class | Function Name of the SFXXMLSAXParser class | Description |
---|---|---|
SFXXMLDOMParser::GetDoNamespaces | SFXXMLSAXParser::GetDoNamespaces | Get the value of the flag to process the namespace. |
SFXXMLDOMParser::GetDoSchema | SFXXMLSAXParser::GetDoSchema | Get the value of the flag to process the schema. |
SFXXMLDOMParser::GetValidationSchema | SFXXMLSAXParser::GetValidationSchema | Get the value of the flag to validate the XML document with the schema. |
SFXXMLDOMParser::GetLoadExternalDTD | SFXXMLSAXParser::GetLoadExternalDTD | Get the value of the flag to load the external DTD file. |
SFXXMLDOMParser::GetValidationDTD | SFXXMLSAXParser::GetValidationDTD | Get the value of the flag to validate the XML document with the DTD. |
SFXXMLDOMParser::GetDocument | ------ | Get the root node of the DOM tree. |
SFXXMLDOMParser::GetCreateCommentNodes | ------ | Get the value of the flag to generate the comment node. |
SFXXMLDOMParser::GetDoIndent | SFXXMLSAXParser::GetDoIndent | Get the value of the flag to indent the XML document. |
Helper function
Table 19.9. Helper function
Function Name of the SFXXMLDOMParser class | Description |
---|---|
SFXXMLDOMParser::GetFirstChildElement | Get the first child Element node of the Element node with the specified name. |
SFXXMLDOMParser::GetFirstChildElementNS | Get the first child Element node of the Element node with the specified namespace URI and local name. |
SFXXMLDOMParser::GetNextSiblingElement | Get the next sibling Element node of the Element node with the specified name. |
SFXXMLDOMParser::GetNextSiblingElementNS | Get the next sibling Element node of the Element node with the specified namespace URI and local name. |
Helper functions | |
---|---|
Only available for SFXXMLDOMParser, not available for SFXXMLSAXParser |
Function of Parsing with SFXXMLSAXParser | |
---|---|
To parse by using SFXXMLSAXParser, it is necessary to inherit from the SFXXMLDefaultHandler class for setting a handler interface to notify events. |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |