> Expat4D Home > Documentation > Command Reference

xml_SetElementHandler ( parserID; startHandler; endHandler )


  • --> parserID : longint
  • --> startHandler : string[31]
  • --> endHandler : string[31]

Sets the two handler methods which will be called when start and end tags are found in the XML document. Both a start handler and an end handler must be provided. You do not need to set element handlers, but in most cases you will want to.

Each handler method must exist in your database, and should be set up to the parameters as shown in the example below.

`Method: handler_startElement (parser; elementName; numberOfAttributes)

C_LONGINT($1;$parser)
C_TEXT($2;$elementName)
C_LONGINT($3;$numberOfAttributes)

$parser:=$1
$elementName:=$2
$numberOfAttributes:=$3

tagDepth:=tagDepth+1

`...
   

`Method: handler_endElement (parser; elementName)

C_LONGINT($1;$parser)
C_TEXT($2;$elementName)

$parser:=$1
$elementName:=$2

tagDepth:=tagDepth-1

`...
   

`Method: parseXML (text)

C_TEXT($1;$xmlText)
$xmlText:=$1

C_LONGINT($parser)
$parser:=xml_ParserCreate("")
xml_SetElementHandler($parser;"handler_startElement";"handler_endElement")

C_LONGINT($errorCode)
$errorCode:=xml_Parse($parser;$xmlText;1)
xml_ParserFree($parser)
   
  Expat4D Logo

Developer Documentation

Creating Parsers, Destroying Parsers, Parsing Text

Configuring Handler Methods

Position and Error Reporting Functions

Miscellaneous Functions

Output Buffer Functions

Error Codes


> Expat4D Home > Documentation > Command Reference

Last Modified: 27th April 2001 at 9:00 PM