XML-Parser * XML. (no Parse needed)

<< Click to Display Table of Contents >>

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

XML-Parser * XML. (no Parse needed)

XML.Parse from Var - Parse XML-Data from Variable

Previous Top Next


MiniRobotLanguage (MRL)

 

XML.Parse from Var

XML.Parse

XML.Par

Get XML-Data that is already inside a Variable

 

 

Intention

 

This command is used to Load XML-Data from a Variable. During execution of this command, the XML-Parser will "Interpret" the XML-Data and decide

    Where Tags Start and End

    where Attributes start and end

    where names of tags and attributes start and end

 

It will then internally create a internal set of flags that is a 1:1 description of the interpreted XML-Data. Based on these flags all the complex XML.-Subcommands do their work.

 

Therefore most of the XML.-Subcommands require a XML-File to be loaded or Parsed prior they can set to work.

Note that the Load-Command will transparently call the Parse command, after having first load the XML-File into internal Memory.

 

Usage is very simple:

 

$$XMF=?pfad\Small_XML.txt

' We load the XML-Data into a Vaariable

CFF.$$XMF|$$XML

' Now we are going to parse it

XML.Parse|$$XML

 

We can find out if we had errors during parsing using the TImeout-Flag.

Or we can add a third Parameter that will be zero if there are any errors.

 

XML.Parse|$$XML|$$RES

 

If the Parsing was successfiul, $$RES will contain a value for XML-Root,

that is the Byte-Adress of the first "<" in the XML-Data. It will always be larger then zero.

 

If the result $$RES is zero, then the parsing was nut successful. In this case you may find an Parsing Error on the TOS (To of Stack).

 

 

 

 

Syntax

 

 

XML.Parse|P2[|P3]

 

P2 - Variable with XML-Data. XML-Data can contain $cr, $lf or not.

P3 - Variable to return the result. The result is 0 in case

    of parsing errors. Otherwise the result is >0 and contains the

    value XML_Root.

 

 

Parameter Explanation

 

-

 

 

 

Example

 

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

' XML.Parse.-Sample

' We are looking for the Tag below, extracting an attribute-value

' "SQNumber".

' <Patch

'  PatchName="SQLServer2008-KB2716433-x86.exe" SQNumber="Q2716433">

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

$$XMF=?pfad\Small_XML.txt

' We load the XML-Data into a Vaariable

CFF.$$XMF|$$XML

' Now we are going to parse it

XML.Parse|$$XML

'XML.Dump

' 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

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

XML.goto first node

XML.get pos|$$POS

PRT.Actual Position at first node is: $$POS

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

' We use a Hi-Level Search here.

XML.search name and attribute|{&EXACT:Patch}|SQNumber

$$REA=$$000

PRT.MY new position is: $$REA

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

XML.attrib value by name|SQNumber|$$RES

PRT.The Value of the attribute is: $$RES

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

PRT. We are going to Dump 4 Bytes

XML.Dump|$$REA|($$REA+4)

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

MBX.!

ENR.

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

' Error Handler

:Lab_Err

XML.get error|$$ERT

DBP.$$ERT

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">

<SPS>

<SP SPName="SP3"/>

<SP SPName="SP4"/>

<SP SPName="SP5"/>

<SP SPName="SP6"/>

<SP SPName="SP6A"/>

</SPS>

</Product>

<Patch PatchName="SQLServer2008-KB2716433-x86.exe" SQNumber="Q2716433">

<DL SFN="SQLServer2008-KB2716433-x86.exe" FS="188008400">

<SURLS>

 

 

 

 

Remarks

 

-

 

 

 

Limitations:

 

-

 

 

See also:

 

  ! Smart Package Robot 's XML-Features

  ! SPR - XML-Parser Flags

  XML. - eXtended Markup Language

  lf - load file