<<

Contents

Search

>>

 

XML_PARSER

 

 

Function

 

 

Syntax:

XML_PARSER(<Filename>,<Filter>,<Macroname>)

 

<Filename>

= <STRING-EXPRESSION>

<Filter>

= <STRING-EXPRESSION>

<Macroname>

= <MACRONAME>

 

 

Meaning:

XML_PARSER parses a XML file and calls the macro <Macroname> each time an element has been processed.

 

A XML file consists of a sequence of nested elements, e.g. <name>Smith</name>.

<name> is called begin element, Smith is called element value and </name> is called end element.

 

The macro <Macroname> is called three times while an element is processed. In the macro EBUS_DATA$ contains the element name resp. the element value and EBUS_DATA contains the information why the macro has been called.

 

 

Execution of macro

EBUS_DATA

EBUS_DATA$ contains

1.

After processing a begin element

1

the element name without <>, e.g. name

2.

After processing an element value

2

the element value, e.g. Smith

3.

After processing an end element

3

the element name without <> and without /, e.g. name

 

While a XML file is parsed EBUS_DATA$ may contain linefeeds, tabulators and blanks. With <Filter> these characters can be ignored. If <Filter> contains 'l' linefeeds are ignored, if <Filter> contains 't' tabulators are ignored and if <Filter> contains 'b' blanks are ignored.

 

XML_PARSER returns the following result values:

 

1

The XML file has been parsed successfully.

-1

The structure of the XML file is invalid.

-2

<Filename> contains the empty string "".

-3

The file <Filename> does not exist.

 

Parameter:

Filename

XML filename

Filter

Filter

Macroname

Macroname

 

Sample:

RET% = PARSE_XML("Test.xml","tlb",PROCESS.XML)

IF RET% <> 1 THEN ERRORMES = "Error " + STR$(RET%) ENDIF

 

Macro PROCESS.XML:

 

CASE EBUS_DATA

  OF 1 // EBUS_DATA$ contains the begin element, e.g. "name"

 

  OF 2 // EBUS_DATA$ contains the element value, e.g. "Smith"

 

  OF 3 // EBUS_DATA$ contains the end element, e.g. "name"

ENDCASE

 

See also:

XML_GET_NUMBER_OF_ATTRIBUTES

XML_GET_ATTRIBUTE_NAME$

XML_GET_ATTRIBUTE_VALUE$

EBUS_DATA

EBUS_DATA$