XML-Parser * XML. (after Parse)

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > XML-Parser > XML. - after parse >

XML-Parser * XML. (after Parse)

XML.Attrib by Name

Previous Top Next


MiniRobotLanguage (MRL)

 

XML.Attrib by Name

XML.abn

Get complete attributes from an XML-Tag "by name"

 

 

Intention

 

This command is used to retrieve an attribute from an XML-Data Tag.

 

<Product ProductName="STATION 10" Name="Value">

 

This Tag has two attributes:

 

Number 1:

ProductName="STATION 10"

 

and Number 2:

 

Name="Value"

 

You could retrieve then using

 

XML.abm|productname|$$RES

 

to get Attribute Nr.1 into $$RES

 

or

 

XML.abm|&EXACT:Name|$$RES

 

to get Attribute Nr.2 into $$RES

 

As you can use "Parts of a Name" to specify the name of the attribute, simply writing "Name" would possibly bring you the first attribute instead of the second.

 

You can and need to use 3.2 Standard-Search Pattern to specify the name of the attribute that you want. For example, you can use:

 

XML.abm|{Pro&NDTHEN:Name}&OR:PName|$$RES

 

to specify a Name of an attribute. THis way you can also specify alternative names,

for exaple if you have to analyze different languages.

 

To Split the attributes you can use the

 

XML.spl|$$ERG|$$NAM|$$VAL

PRT.It can be splitted into: $$NAM and $$VAL

 

command.

 

After this command, the actual position is on the attributes End.

To get back to the start of the attribute, use:

 

XML.siu|start attribute

 

This will set the actual position to the start of the attribute.

 

 

 

 

Syntax

 

 

XML.Attrib by Name|P2[|P3][|P4]

 

 

 

Parameter Explanation

 

P2 - Variable with the name of the attribute that should be retrieved.

          You can and need to use 3.2 Standard-Search Pattern to specify the name

          of the attribute that you want.

 

P3 - (optional) Variable to return the result. The result is "" in case

          no such attribute was found. If P3 was omitted the result is placed on TOS.

 

P4 - (optional) Count. In case there are multiple variables with the same name, you

          can specify the number of the attribute that you want. If omitted "1" is the

          default number.

 

 

 

 

Example

 

'***********************************

'

'***********************************

'Prototype für IML.

$$XMF=?pfad\Small_XML.txt

NEF.$$XMF

 MBX.File $$XMF was not found!

 GTO.enx

EIF.

' Now we are going to parse it

XML.Load File|$$XMF

' We check if there are errors

JIT.Lab_Err

' We get the "actual position" - after parsing.

XML.get pos|$$POS

PRT.Actual Position after Parsing is: $$POS

XML.get len|$$LEN

PRT.Actual Size of XML-Data is: $$LEN

' Hier gehts los

PRT.------------------------

XML.abn|ncod&ANDTHEN:g|$$ERG

PRT. The second attribute is: $$ERG

XML.spl|$$ERG|$$NAM|$$VAL

PRT. It can be splitted into: $$NAM and $$VAL

XML.abn|ver|$$ERG

PRT. The first attribute is: $$ERG

XML.spl|$$ERG|$$NAM|$$VAL

PRT. It can be splitted into: $$NAM and $$VAL

XML.sdn|{&EXACT:Product}

XML.get pos|$$POS

PRT.Actual Position after Search is: $$POS

XML.abn|lik|$$ERG

PRT. The second attribute is: $$ERG

XML.spl|$$ERG|$$NAM|$$VAL

PRT. It can be splitted into: $$NAM and $$VAL

XML.abm|uctn|$$ERG

PRT. The first attribute is: $$ERG

XML.spl|$$ERG|$$NAM|$$VAL

PRT. It can be splitted into: $$NAM and $$VAL

MBX.!

:enx

ENR.

'-----------------------------------------------------------

' Error Handler

:Lab_Err

XML.get error|$$ERT

DBP.$$ERT

ENR.

 

This is the result of the sample script:

 

graphic

 

 

 

Remarks

 

-

 

 

 

Limitations:

 

-

 

 

See also:

 

  ! Smart Package Robot 's XML-Features

  ! SPR - XML-Parser Flags

  XML. - eXtended Markup Language

  par - parse from var

  abm - Attrib by Number

  abv - Get Attrib by Value

  avbn - Attrib Value by Name