Allows to get tags values into XML file, or the value of an attribute.
Syntax
CHGVAR |
VAR(&CMD) VALUE('PARSEXML') |
CHGVAR |
VAR(&PARM1)
VALUE(' [;Attribut="Attribute
name"] |
CHGVAR |
VAR(&PARM2) VALUE(' ') |
CALL |
PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 + &PARM2 &RESULT) |
Parameters
Parameters |
|
Parm1 |
XMLFile : Path to the XML file.
Tags: List of tags that you want to retrieve value. Tags are separated by a semicolon (;). Attribut: name
of the attribute of the tag whose value we want to retrieve.
|
RESULT |
In return, the list of values corresponding to the list of tags, separated by a semicolon (;). If the Attribute parameter is specified, you will have the value of the attribute in return.
|
Example 1
Assuming we have this XML file, and we want to retrieve the following values (in red):
<?xml version="1.0" encoding="utf-8"?>
<tnsb:Notification>
<tnsb:NotificationType>GENERAL</tnsb:NotificationType>
<tnsb:Request>
<tnsb:Type>PAPER</tnsb:Type>
<tnsb:TrackId>test_C33012646115</tnsb:TrackId>
<tnsb:DepositId>25527400032</tnsb:DepositId>
<tnsb:ReceptionDate>01/10/2015 1:17:34</tnsb:ReceptionDate>
<tnsb:FoldsCount>1</tnsb:FoldsCount>
<tnsb:Status>ACCEPT</tnsb:Status>
<tnsb:PaperOptions>
<tnsb:EnvelopeType>C6</tnsb:EnvelopeType>
<tnsb:PrintDuplex>false</tnsb:PrintDuplex>
<tnsb:DocumentCount>1</tnsb:DocumentCount>
<tnsb:BilledPageCount>2</tnsb:BilledPageCount>
<tnsb:PageCount>2</tnsb:PageCount>
</tnsb:PaperOptions>
</tnsb:Request>
</tnsb:Notification>
If we execute the following command:
LNCCMDR CMD(PARSEXML) +
PARM1('XMLFILE="\\ADX01\Docs\notification.xml"; +
Tags="tnsb:Notification.tnsb:Request.tnsb:TrackId;tnsb:N+
otification.tnsb:Request.tnsb:ReceptionDate+
;tnsb:Notification.tnsb:Request.tnsb:Status') RESULT(&RESULT)
In
return, we get:
*MSGtest_12;01/10/2015 1:17:34;ACCEPT
Example 2
Assuming we have this XML file, and we want to retrieve the following values (in red):
<?xml version="1.0" encoding="UTF-8"?>
<records>
<record name="export" type="extra" date="20200402">
<produits quantity="8" name="CatA">
<produit name="A1" value="AS1254"/>
<produit name="A2" value="UIPLH"/>
<produit name="A3" value="125698YT"/>
<produit name="A4" value="KJZ745"/>
<produit name="A5" value="POJ523"/>
<produit name="A6" value="127YUI"/>
<produit name="A7" value="RTFG58"/>
<produit name="A8" value="GHUP263"/>
The following commands will have to be executed:
LNCCMDR CMD(PARSEXML) +
PARM1('XMLFILE="C:\test\produits.xml"+
;Tags="records.record";Attribut="type"') +
RESULT(&RESULT)
LNCCMDR CMD(PARSEXML) +
PARM1('XMLFILE="C:\test\produits.xml"+
;Tags="records.record.produits.produit[6]"+
;Attribut="value"') RESULT(&RESULT)
Please note that the tag index starts at 0. To have the seventh product, we put the index = 6