$xml

Allows you to parse and interprete XML files.
Syntax
    see Documentation
Documentation

 

 

Parameter0

Parameter1

Parameter 2

Parameter3

Parameter4

Parameter5

Parameter6

COMMAND

DOCNAME

ERM-Name

Data/URL

Bytes

per

Charter

Content Type

Base URL

Down

-

-

-

-

-

-

getAttributeName

-

-

-

-

-

-

getAttributeType

-

-

-

-

-

-

getAttributeValue

-

-

-

-

-

-

getName

-

-

-

-

-

-

getType

-

-

-

-

-

-

getValue

-

-

-

-

-

-

hasChildren

-

-

-

-

-

-

hasParent

-

-

-

-

-

-

Next

-

-

-

-

-

-

nextAttribute

-

-

-

-

-

-

Parse

X

none

normal

pendantic

X

O

O

O

setDocument

X

-

-

-

-

-

Up

-

-

-

-

-

-

O optionally

X used

- unused

 

$xml{down}

With this command you can jump down to the next level of the elements. With the command  $xml{next} you can switch between the elements of this level. The command returns a boolean value 1 for true and 0 for false. The backward command to xml{down} is $xml{up}.

                                                              

$xml{getAttributeName}

Returns the name of the selected attribute, provided an element has attributes.

                                              

$xml{getAttributeType}

Return the type of the selected attribute.

 

$xml{getAttributeValue}

Returns the value of the selected attribute.

 

$xml{getName}

Returns the name of the selected element. The command $xml{next},$xml{down} and $xml{up} can be used to switch between the elements.

 

$xml{getType}

Returns the type of the selected element.

 

$xml{getValue}

Returns the value of the selected element.

 

$xml{hasChildren}

Returns a boolean value if the element has children or not. If the element  has children it returns 1 or 0 otherwise.

(We used the name children for a subtree in the three hierarchy of an xml file.)

 

$xml{hasParent}

This ist the backward command for $xml{hasChildren} and checks if the selected  element has parents. It returns also a boolean value.

 

$xml{next}

With this command you can switch to the next element in the xml file. It's used in combination with $xml{down}and

$xml{up} to select the element you need.

 

 

$xml{nextAttribute}

If an element has attributes you can switch  with this command to the next attribute of this element. The command returns a boolean value 1 for true an 0 for false.

 

$xml{parse}{DocName} {ERM-Name} {Data/URL} {BytesPerCharter} {Content Type}{BaseURL}

 

DocName - Set the temp name for the parsed xml file. This name you can use  with $xml{setDocument}{DocName} to activate a parsed xml file.

 

ERM-Name - Error report mode based on the  API's for XML

-none ;Parameter  5,6,7 are unused see sample2 for more infos

-normal  Parameter  5,6,7 are unused

-pedantic Parameter  5,6 are used and 7 is optionally used

 

Data/URL -This is the path or  URL to the xml file which will parsed

 

BytesPerChar -When you import a xml file from an URL you must set how much bytes per character will be used . (This is needed when you import the xml file from a URL)

 

Content Type - set the content type to the format of the xml file  (this is needed when you import the xml file from a URL)

 

BaseURL(optionally) - This sets the path of your own DTD - config files (this parameter can be set optionally)

 

The following combinations of parameters can be used.

 

$xml{parse}{DocName}{ERM-Name}{Data/URL}

$xml{parse}{DocName}{ERM-Name}{Data/URL}{BaseURL}

$xml{parse}{DocName}{ERM-Name}{Data/URL}{BytesPerCar}{Content Type}{BaseURL}

 

§xml{setDocument}{DocName}

This command can be used to activate a xml file.  {DocName}  is the name  you set when you parse the xml file.

 

$xml{up}

Opposite to $xml{down} . Allows you to jump up to the previous level. The command returns a boolean value 1 for true and 0 for false.

Examples

XML sample files

 

1. XML sample file (Save the sample file as sample.xml in the static/public/ directory of your SITEFORUM account.)

 

<?xml version="1.0" encoding="ISO-8859-1"?>

 

<root_element>

                <user>

                                <address>

                                                <key name="street"                value="Konrad-Zuse-Str. 15">

                                                <key name="city"                  alue="Erfurt">

                                                <key name="state" value="Germany">

                                </address>

                                <name>

                                                <key name="firstname"          value="Klaus">

                                                <key name="lastname"           value="Mustermann">

                                </name>

                                <phone>

                                                <key name="work phone"     value="03614262209">

                                                <key name="cellphone"         value="017147110815">

                                                <key name="fax"                    value="03614262299">

                                                <key name="private phone" value="03614262510">

                                </phone>

                </user>

</root_element>

 

2. XML sample file (Save the sample file as sample2.xml in the static/public/ directory of your account.)

 

<?xml version="1.0" encoding="ISO-8859-1"?>

 

<root_element>

                <address>

                                <name>SITEFORUM</name>

                                <street>Konrad-Zuse-Str.15</street>

                                <city>Erfurt</city>

                                <state>Germany</state>

                </address>

</root_element>

 

3. XML sample file (Save the sample file as sample3.xml in the static/public/ directory of your account.)

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE  root_element SYSTEM "sample3.dtd">

<root_element>

                <address>

                                <name>Schlenzig</name>

                                <street>Kelterweg 22</street>

                                <city>Erfurt</city>

                                <state>Germany</state>

                </address>

</root_element>

 

4. XML sample file (Save the sample file as sample4.xml in the static/public/ directory of your account.)

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE root_element SYSTEM "sample4.dtd">

<root_element>

                <address>

                                <name firstname="Dirk" lastname="Schlenzig"/>

                                <street name="Konrad-Zuse-Str." number="15"/>

                                <city zip="99195" name="Erfurt"/>

                </address>

</root_element>

 

DTD sample files

 

1. DTD sample.file (Save this sample DTD as sample3.dtd in the static/public/ directory of your account)

 

<!ELEMENT root_element (address)>

<!ELEMENT address (name, street, city, state)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT street (#PCDATA)>

<!ELEMENT city (#PCDATA)>

<!ELEMENT state (#PCDATA)>

 

2. DTD sample.file (Save this sample DTD as sample4.dtd in the static/public/ directory of your account)

 

<!ELEMENT root_element (address)>

<!ELEMENT address (name, street, city)>

<!ELEMENT name EMPTY>

<!ELEMENT street EMPTY>

<!ELEMENT city EMPTY>

<!ATTLIST name firstname CDATA #REQUIRED>

<!ATTLIST name lastname CDATA #REQUIRED>

<!ATTLIST street name CDATA #REQUIRED>

<!ATTLIST street number CDATA #REQUIRED>

<!ATTLIST city zip CDATA #REQUIRED>

<!ATTLIST city name CDATA #REQUIRED>

 

 

SITEFORUM sample templates

 

1. Sample Template to parse the file sample.xml (read's the attributes of the address element)

 

$// parse the file sample.xml without error analysis none DTD-file is needed.

$xml{parse}{sample}{none}{public://sample.xml}

 

$// the while loop switches step by step from the first to the last element of the root level

$while{$xml{next}}

                {

                $// check if the element has the name "user"

                $if{$equals{$xml{getName}}{user}}

                                {

                                $// if it's true and the element has children jump to the next level of this element with $xml{down}

                                $if{$xml{hasChildren}}

                                                {

                                                $xml{down}

                                                }

                                $// the while loop switch step by step from the first to the last element of the second level

                                $while{$xml{next}}

                                                {

                                                $// check if the element has the name "address"

                                                $if{$equals{$xml{getName}}{address}}

                                                                {

                                                                $// if it's true and the element has children this jump to the next level of this element

                                                                §// with $xml{down}

                                                                $if{$xml{hasChildren}}

                                                                                {

                                                                                $xml{down}

                                                                                }

                                                                $// the while loop switch step by step from the first to the last element of the third level

                                                                $while{$xml{next}}

                                                                                {

                                                                                $// this while loop switch step by step to all attributes of the selected element

                                                                                $while{$xml{nextAttribute}}

                                                                                                {

                                                                                                $// check if the attribute has the name  "name"

                                                                                                $if{$equals{$xml{getAttributeName}}{name}}

                                                                                                                {

                                                                                                                $// it's true get the value of this attribute

                                                                                                                $xml{getAttributeValue} :

                                                                                                                }

                                                                                                                                {

                                                                                                                                $// it's false it check  if the name of the attribute

                                                                                                                                $// "value"

                                                                                                                                $if{$equals{$xml{getAttributeName}}{value}}

                                                                                                                                                {

                                                                                                                                                $// it's true get  the value of this attribute

                                                                                                                                                $xml{getAttributeValue}<br>

                                                                                                                                                }

                                                                                                                                }

                                                                                                }

                                                                }

                                                                $// jump up to the next  higher level

                                                                $xml{up}

                                                                }

                                                }

                                $// jump up to the next higher level

                                $xml{up}

                                }

                }

 

                                Result for the 1. Sample Template

 

                                street :Konrad-Zuse-Str. 15

                                ctiy :Erfurt

                                state :Germany

 

 

2. Sample Template to parse the file sample2.xml (this sample template jump step by step to the name element and read the element value )

 

$xml{parse}{sample2}{none}{public2://sample2.xml}

 

$xml{next}<br>                                                                      (Line3)

$xml{getName}<br>                                                              (Line4)

                $xml{next}<br>                                                      (Line5)

                $xml{getName}<br>                                              (Line6)

                $xml{down}down<br>                                          (Line7)

                                $xml{next}<br>                                      (Line8)

                                $xml{getName}<br>                              (Line9)

                                $xml{next}<br>                                      (Line10)

                                $xml{getName}<br>                              (Line11)

                                $xml{down}down<br>                          (Line12)

                                                $xml{next}<br>                      (Line13)

                                                $xml{getValue}<br>               (Line14)

 

                                Result for the 2. Sample Template

 

                                1                                                              (Result of Line3)

                                #text                                                       (Result of Line4)

                                1                                                              (Result of Line5)

                                address                                                  (Result of Line6)

                                down                                                      (Result of Line7)

                                1                                                              (Result of Line8)

                                #text                                                       (Result of Line9)

                                1                                                              (Result of Line10)

                                name                                                       (Result of Line11)

                                down                                                      (Result of Line12)

                                1                                                              (Result of Line13)

                                SITEFORUM                                               (Result of Line14)

 

Please note: When the xml file is parsed with ERM none every linebreak or whitespace is interpreted as #text when

$xml{getName} is used.

 

3. Sample Template to parsing the file sample3.xml

(on this template the sample3.xml file is parsed with ERM pedantic. It's recommended that the following DTD file is stored with

the name sample3.dtd in the static/public directory.)

 

$xml{parse}{sample3}{pedantic}{public2://sample3.xml}{public2://}              

 

$xml{next}<br>                                                                      (Line3)

$xml{getName}<br>                                                              (Line4)

                $xml{down}down<br>                                          (Line5)

                                $xml{next}<br>                                      (Line6)

                                $xml{getName}<br>                              (Line7)

                                $xml{down}down<br>                          (Line8)

                                                $xml{next}<br>                      (Line9)

                                                $xml{getValue}<br>               (Line10)

 

                                Result for the 3. Sample Template

 

                                1                                                              (Result of Line3)

                                address                                                  (Result of Line4)

                                down                                                      (Result of Line5)

                                1                                                              (Result of Line6)

                                name                                                       (Result of Line7)

                                down                                                      (Result of Line8)

                                1                                                              (Result of Line9)

                                Schlenzig                                               (Result of Line10)

 

4. Sample Template to parsing the file sample4.xml

(On this template the sample4.xml file is parsed with ERM pedantic It's recommend that the following DTD file is stored with

the name sample4.dtd in the static/public directory.)

 

$xml{parse}{sample4}{pedantic}{public2://sample4.xml}{public2://}              

 

$xml{next}<br>                                                                                                                      (Line3)

$xml{getName}<br>                                                                                                              (Line4)

                $xml{down}down<br>                                                                                          (Line5)

                                $xml{next}<br>                                                                                      (Line6)

                                $xml{getName}<br>                                                                              (Line7)

                                                $xml{nextAttribute}<br>                                                       (Line8)

                                                $xml{getAttributeName}=$xml{getAttributeValue}<br>(Line9)

 

                                Result for the 3. Sample Template

 

                                1                                                              (Result of Line3)

                                address                                                  (Result of Line4)

                                down                                                      (Result of Line5)

                                1                                                              (Result of Line6)

                                name                                                       (Result of Line7)

                                1                                                              (Result of Line8)

                                firstname=Dirk                                      (Result of Line9)

 

GroupSpecial
Minimum required transaction-mode:READ=IO
Required scripting permission of the developerPERMISSION_FL_BASIC
Minimum parameters1
Maximum parameters 7