<< Click to Display Table of Contents >> Navigation: 3. Script Language > XML-Parser > XML. - after parse > XML-Parser * XML. (after Parse) |
MiniRobotLanguage (MRL)
XML.Search Name and Attribute up
XML.snaup
Search specified Tags with specified attributes
Intention
This command is used to search a defined Place in the XML-Data. To specify this place, you can give the Tag-Name and the name of an attribute inside of the Tag.
To search the following Tag:
<Patch PatchName="SQLServer" SQNumber="Q2716433">
you could use this line:
XML.snaup|Patch|SQNum
For this command you need to provide the name as well as the attribute-Name.
If you want to search only "by Name" you can use the
commands.
This command will search from the current position upwards.
To search downwards, use: sna - Search Name and Attribute
If you have several fitting Tags or attributes with the same name, you can specify a count in P3 and P4.
XML.sna|Patch|SQNum|2|3
In this case, the 2nd Tag with a name and attribute that matches the specification is a valid result.
Only the 3rd attribute that matches the attribute specification will be valid in this case.
It is important to understand that the first counter - in this case P2 will count the total match of both - name and attribute . while the second counter P3 only defines the count of the attribute in the actual examined tag.
Example:
<Patch PatchName="SQLServer" SQNumber="Q2716433" SANumber="Q2716433" SCNumber="Q2716433">
Assume that you do not know the exact name of the third attribute of the tag you are looking for. You could write:
XML.snaup|Patch|S&ANDTHEN:Num|1|3
Note the use of 3.2 Standard-Search Pattern that are perfect for these cases.
Using the Pattern, any attribute Name that starts with a "S" and then has following the word "Num" will be fine.
Syntax
XML.sna|P2|P3[|P4][|P5]
Parameter Explanation
P2 - Variable with the name of the Tag that should be searched for.
You can and need to use 3.2 Standard-Search Pattern to specify the Tag-Name.
P3 - 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) Count. In case there are multiple Tags and attributes with
names that fit the description, you can specify the number of the Tag Name
that you want.If omitted "1" is the default number.
P3 does not only count "valid Tag Names" but valid results that have a
fitting Tag name as well as a fitting attribute name.
P4 - (optional) Count. In case there are multiple attributes with the same name, you
can specify the number of the attribute that you want. If omitted "1" is the
default number.
Example
'***********************************
$$XMF=?pfad\SQ_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
' Here we search ...
PRT.------------------------
XML.sna|Patch|SQNum
XML.get pos|$$POA
PRT.Actual Position after sdn is: $$POA
PRT.------------------------
XML.Dump|($$POA-3)|($$POA+24)
PRT.------------------------
XML.snaup|Prod|likn
XML.get pos|$$POA
PRT.Actual Position after sdn is: $$POA
PRT.------------------------
XML.Dump|($$POA-3)|($$POA+24)
PRT.------------------------
MBX.!
:enx
ENR.
'-----------------------------------------------------------
' Error Handler
:Lab_Err
XML.get error|$$ERT
DBP.$$ERT
ENR.
This is the result of the sample script:
Remarks
-
Limitations:
-
See also:
• ! Smart Package Robot 's XML-Features
• XML. - eXtended Markup Language
• sna - Search Name and Attribute
•