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.Get Attrib by Value

Previous Top Next


MiniRobotLanguage (MRL)

 

XML.Get Attrib by Value

XML.abv

Get attribute value by specifying the attribute 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.abv|statio|$$RES

 

to get Attribute Nr.1 into $$RES

 

or

 

XML.abv|valu|$$RES

 

to get Attribute Nr.2 into $$RES

 

You can use "Parts of a Value" to specify the Value of the attribute that you want.

 

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

 

XML.abv|Va&AND:e|$$RES

 

to specify a Value of an attribute. This way you can also specify alternative Values,

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.Get abv|P2[|P3][|P4]

 

 

 

Parameter Explanation

 

P2 - Variable with the Value 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 value, 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.abv|utf|$$ERG

PRT. The second attribute is: $$ERG

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

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

XML.abv|1.0|$$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.abv|NTW|$$ERG

PRT. The second attribute is: $$ERG

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

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

XML.abv|work&AND:4|$$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

  abn - Attrib by Name