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 Value by Name

Previous Top Next


MiniRobotLanguage (MRL)

 

XML.Attrib Value by Name

XML.avbn

Get an attributes value by specifying the attributes name

 

 

Intention

 

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

For this you have to set the current position to the Tag that has these attributes, that you want. Then you can use this command.

 

Here is an example for an XML-Tag with two attributes.

 

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

 

This Tag has two attributes:

 

Number 1:

ProductName="STATION 10"

 

and Number 2:

Name="Value"

 

You could retrieve these attributes values using

 

XML.avbn|productname|$$RES

 

to get the value of Attribute Nr.1 into $$RES

 

or

 

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

 

to get the value of 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 value of 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.avbn|{Pro&NDTHEN:Name}&OR:PName|$$RES

 

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

for example if you have to analyze different languages.

 

 

 

 

Syntax

 

 

XML.avbn|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

'Here we start

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

XML.avbn|ver|$$ERG

PRT.The attribute value is: $$ERG

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

XML.sdn|{&EXACT:Product}

XML.get pos|$$POS

PRT.Actual Position after Search is: $$POS

XML.avbn|Sha|$$ERG

PRT.The attribute value is: $$ERG

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

MBX.!

:enx

ENR.

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

' Error Handler

:Lab_Err

XML.get error|$$ERT

DBP.$$ERT

ENR.

ENR.

 

This is the result of the sample script:

 

graphic

 

Here is the important part of the used XML-Data that is analyzed here:

 

<?xml version="1.0" encoding="UTF-8"?>

<!-- comment attrib="Hall"-->

<PatchInformation XMLVersion="1.0000.0000.4918" XMLLastUpdated="1/30/2010" PatchCount="1261">

<Products>

<Product ProductName="WINDOWS NT 4.0" SName="NTW">

 

You can find the XML-Sample-Data file in the Installation folder in the Samples-Folder "XML".

 

 

 

Remarks

 

-

 

 

 

Limitations:

 

-

 

 

See also:

 

  ! Smart Package Robot 's XML-Features

  ! SPR - XML-Parser Flags

  XML. - eXtended Markup Language

  par - parse from var

  abn - Attrib by Name

  abv - Get Attrib by Value