<< Click to Display Table of Contents >> Navigation: 3. Script Language > XML-Parser > ! XML. - eXtended Markup Language |
MiniRobotLanguage (MRL)
XML. Command
Load, Parse and Analyze XML-Data
Intention
This command is a universal command to load, parse and analyze XML-Files and XML-Data.
Depending on the used Subcommand, more then 50 commands are available to handle your XML-Files.
There are 2 general sort of Sub-commands.
1. Commands that can be used anytime.
2. Commands that require an XML-File to be loaded or parsed before they can be used.
Most commands are in this group.
We can split these second sort of commands in further three groups:
a) Complex commands like:
XML.search name and attribute|$$NAM|$$ATN
b) Low level commands. These are all commands that work directly with the
XML-Flags, like :
XML.search all up|$$FLG
c) Simple commands like:
XML.get asc|$$NUM|$$RES
Debugging XML-Scripts
You can use the commands:
XML.Print
XML.Dump
to get more or less detailed Print-Outs of your XML-Data. There is an example Script below in the examples section.
Internal notes
Additionally there are few commands that enable you to change the loaded XML-Data.
Here is an important rule:
Changing the internal XML.-Data after Parsing is supported, but any change in Size would invalidate all previous XML-Parsing from that changed byte down to the end of the XML-Data. Therefore a "ReParsing" Option is available and will sometimes be automatically called.
This is due to the 1:1 Synchronity of the XML-Flags with the XML-Data Bytes that is eventually getting lost.
Even if you change large portions of XML-Data without changing the size, you may need to re-parse the XML-Data to have valid XML-Flags.
Note: If you do not change the XML-Data Size, the re-parsing is not done automatically!
You can make a manual "ReParse" of the changed XML-Data using the Subcommand:
XML.ReParse
Here is an example for an automatic ReParse. If you use (example):
XML.set xml part|6|6|sy
the Subcommand will automatically "re-parse" the XML-Data because the size of the XML-Data was changed during the command execution.
On very large XML-Files this may take always a few seconds, On small files the delay should not be noticed. Also problems while parsing the XML-Data will be reported just as if you had been called the "Parse" Subcommand.
You can make all changes in a way that the size of the data is not changed and the XML-Flags stay valid. This will prevent an internal Re-Parsing. You could for example change
<namex >
to
<namey >
using
XML.set chr|5|y
this will not change the size of the XML-Data and therefore the synchronity between the XML-Data and the flags will stay intact.
Here is another example that show where the problem is. If you change:
<namex >
to
<namesy >
using
$$XML=<namex >
XML.parse|$$XML
XML.Print
XML.set xml part|6|6|sy
XML.Print
MBX.!
then downward from the "s", all XML-Flag Data would loose their "Flags" and therefore the whole Data is being Re-Parsed".
if you plan to make a completely changed XML-Data version of a very large XML-File, i would recommend to just extract portions of the original data, and rebuild it using variables.
Syntax
XML.P1[|P2..Px]
Parameter Explanation
P1 - (optional) Subcommand, one of the following:
See Subfolders in Index
P2 - Px (depend on used Subcommand P1)
Example
'-----------------------------
' Demonstrate XML.-Debug Commands
'-----------------------------
$$XMF=?pfad\Small_XML.txt
XML.load|$$XMF
JIT.Lab_Err
XML.Print
MBX.This is an XML-Printout
XML.Print|$$TXT
DBP.$$TXT
MBX.It can be directed to the Editor-Debug Window.
XML.Dump|20|100
MBX.This is a partial XML-Dump.
XML.Dump
MBX.This is a complete XML-Dump.
ENR.
' Error-Handler
:Lab_Err
XML.get error|$$ERT
DBP.$$ERT
ENR.
END.
'-----------------------------
' Demonstrate several Low Level
' XML._Subcommands
'-----------------------------
$$XMF=?pfad\Small_XML.txt
XML.load|$$XMF
JIT.Lab_Err
' We get the "actual position" - after parsing.
XML.get pos|$$POS
PRT.Actual Position after Parsing is: $$POS
PRT.------------------------
' We use a Low Level Search here.
XML.search all down|"before eq","between"|$$RES
PRT.MY new position is: $$RES
PRT.------------------------
' We evaluate the Level at position 234
XML.get level|234|$$LEV
PRT. The Level (234) is: $$LEV
PRT.------------------------
PRT. We are going to Dump 4 Bytes
XML.Dump|234|238
' We get a single ASC Byte (Text) out of the XML-Data
XML.get asc|234|$$ASC
PRT.The ASC-Value(234) is $$ASC
PRT.------------------------
' We get the Flag-Data of this byte as text
XML.gef flags as text|234
PRT.The Flags at Pos.234 is $$000
PRT.------------------------
' Here is an example on how to calculate with Flag-Values
CAL.$$FLG=128+512+8
XML.flags to text|$$FLG|$$FTX
PRT.Flags are: $$FTX
PRT.------------------------
MBX.!
ENR.
Remarks
-
Limitations:
-
See also:
• ! Smart Package Robot 's XML-Features
•