Parser Component
:icons:font :hardbreaks: :imagesdir: ../../../assets/images :toc-title: Contents :toc:
Description
Parses any text structures. The regular expression method, the JSON search method, and the built-in hypertext analyzer can be used. According to the search string, it generates a response, either cuts out the requested section or a set of them, or determines the number of elements in the specified section of the structure. Complex structures can be parsed by a sequence of "Parser" elements, each of which extracts a certain structure from the document and returns it for transmission to the input of the next element.
The parsed document structure is cached in a specific instance of the script engine to speed up work with one large document of sequential Parser elements.
Index |
|
Short name |
|
Script types |
|
Start module |
|
Mode |
Synchronous |
Icon |
|
Branching type |
Branching, closing |
Properties
| Specification | Description |
|---|---|
Name: Document Code: Visibility condition: no Default: — |
Argument with the contents of the document to be parsed. |
Name: Algorithm Code: Visibility condition: no Default: Regular expressions |
Parsing algorithm. Possible options:
|
Name: Search query Code: Visibility condition: no Default: — |
String with the search query for the selected algorithm. |
Name: Function
Code: Default: Number of elements |
Function for the JSON Parser algorithm. Possible options:
|
Name: Function Code: Visibility condition: yes Default: Number of elements |
Function for the XML Parser algorithm. Possible options:
|
Name: Function Code: Visibility condition: yes Default: Number of groups |
Function for the Regular Expressions algorithm. Possible options:
|
Name: Function
Code: Default: Number of elements |
Function for the HTML Parser algorithm. Possible options:
|
Name: Item number
Code: Default: — |
Parameter for the Regular Expressions algorithm. Specifies the index of an element in the list of elements found by the pattern in the source document. |
Name: Group number Code: Visibility condition: yes Default: — |
Parameter for the Regular Expressions algorithm. Indicates the group number in the list of captured groups of the selected item. It only matters when you specify capture groups in the search query (set off in parentheses in accordance with regular expression syntax). For example, in the document, mom was washing the frame, and Lena was sitting, the template (.)a([^ ])* will find 7 elements, in each of which 3 groups are available: |
Name: Attribute number Code: Visibility condition: yes Default: — |
Parameter for the |
Name: Attribute name Code: Visibility condition: yes Default: — |
Parameter for the |
Name: Result into variable
Code: Default: — |
Variable for storing the result of the operation. |
Name: More requests Code: Visibility condition: no Default: — |
List of sequentially executed additional queries and assignments of results to a variable. Each value in the table represents a search query (analogous to the query field). If the field is filled in, then the main request is executed first, and then all additional requests are executed with the same parameters. The result of each is assigned to its corresponding variable in the table. If any request fails, then:
|
Name: Abort on errors Code: Visibility condition: yes Default: yes |
When performing multiple operations, the default error interrupts the process. The parameter allows you to continue performing the following operations, accumulating error information in a variable. If at least one error occurs, exit is carried out via the Error branch, if it is specified. If a basic operation that is specified separately by the 'query' property and not in the list of multiple operations fails, the process is always aborted. |
Name: Error in variable Code: Visibility condition: no Default: — |
Variable for storing the error. |
Name: Transition Code: Visibility condition: no Default: — |
The component to which control is transferred upon successful completion of the operation. |
Name: Transition, error
Code: Default: — |
Component to which control is transferred upon error. |
Examples
JSON algorithm
Review
-
When parsing an array of objects, you can specify a filter in
(key:value); only objects with the specified key-value pair will be used for further parsing. A filter can only be based on one key-value pair. For example:"msgs"("msgSender":"ab"), "msgs" – contains an array of objects from which objects with the property "msgSender"="ab" will be selected. -
Numbering of array elements starts from 0.
-
When specifying
/DELIMITER=xxx/at the beginning of the query string, the separator will be the specified characters (in this case,/cannot be a separator)
{
"result": "ok",
"errormsg": "",
"info": {
"https://some_url.domain/": {"/tmp/a/www": true}
},
"/x": [
{
"https://some_url.domain/": {"/tmp/a/www": ["first_elem", "sec_elem"]}
}
],
"chat": [
{
"sessId": "uvajoqnx0qcpbjoflxr",
"msgs": [
{
"msgId": 8255,
"msgDt": 1491292390,
"msgData": {
"type": "text",
"data": "Good afternoon. Please choose the question you are interested in."
},
"msgSender": "op"
},
{
"msgId": 8256,
"msgDt": 1491292391,
"msgData": {
"type": "buttons",
"data": "Contact user 6"
},
"msgSender": "ab"
},
{
"msgId": 8257,
"msgDt": 1491292392,
"msgData": {
"type": "buttons",
"data": "Contact user 8"
},
"msgSender": "ab"
}
]
}
]
}
| Search Query | Function | Result |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
. |
|
|
|
|
|
|
|
|
|
|
|
|
XML Algorithm
<configuration version="16">
<folder id="x.okteller.ru" label="x.okteller.ru" path="c:\rtx_mg3\Media\domains\x.okteller.ru" type="readwrite" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="RXYYDPI-SVKNBMF-YADG7WD"></device>
<minDiskFreePct>1</minDiskFreePct>
<versioning></versioning>
<copiers>0</copiers>
<pullers>0</pullers>
<hashers>0</hashers>
<order>random</order>
</folder>
<folder id="okteller.ru" label="okteller.ru" path="c:\rtx_mg3\Media\domains\okteller.ru" type="readwrite" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="RXYYDPI-SVKNBMF-YADG7WD"></device>
<minDiskFreePct>1</minDiskFreePct>
<versioning></versioning>
<copiers>0</copiers>
<pullers>0</pullers>
<hashers>0</hashers>
<order>random</order>
</folder>
<folder id="Common" label="Common" path="c:\rtx_mg3\Media\common" type="readwrite" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="RXYYDPI-SVKNBMF-YADG7WD"></device>
<minDiskFreePct>1</minDiskFreePct>
<versioning></versioning>
<copiers>0</copiers>
<pullers>0</pullers>
<hashers>0</hashers>
<order>random</order>
</folder>
<device id="RXYYDPI-SVKNBMF-YADG7WD" name="Pavel" compression="metadata" introducer="false">
<address>dynamic</address>
</device>
<gui enabled="true" tls="false" debugging="false">
<address>127.0.0.1:8384</address>
<apikey>jeopL9MghPvTmweKDeGcoXhwRtrdaVDP</apikey>
<theme></theme>
</gui>
<options>
<globalAnnounceEnabled>false</globalAnnounceEnabled>
<localAnnounceEnabled>false</localAnnounceEnabled>
<localAnnouncePort>21027</localAnnouncePort>
<localAnnounceMCAddr></localAnnounceMCAddr>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<reconnectionIntervalS>60</reconnectionIntervalS>
<relaysEnabled>false</relaysEnabled>
<relayReconnectIntervalM>10</relayReconnectIntervalM>
<startBrowser>false</startBrowser>
<natEnabled>false</natEnabled>
<natLeaseMinutes>60</natLeaseMinutes>
<natRenewalMinutes>30</natRenewalMinutes>
<natTimeoutSeconds>10</natTimeoutSeconds>
</options>
</configuration>
| Search Query | Function | Result |
|---|---|---|
|
|
<folder id="Common" label="Common" path="c:\rtx_mg3\Media\common" type="readwrite" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="RXYYDPI-SVKNBMF-YADG7WD"/>
<minDiskFreePct>1</minDiskFreePct>
<versioning/>
<copiers>0</copiers>
<pullers>0</pullers>
<hashers>0</hashers>
<order>random</order>
</folder>
<folder id="rootdomain.ru" label="rootdomain.ru" path="c:\rtx_mg3\Media\domains\rootdomain.ru" type="readwrite" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="RXYYDPI-SVKNBMF-YADG7WD"/>
<minDiskFreePct>1</minDiskFreePct>
<versioning/>
<copiers>0</copiers>
<pullers>0</pullers>
<hashers>0</hashers>
<order>random</order>
</folder>
<folder id="x.rootdomain.ru" label="x.rootdomain.ru" path="c:\rtx_mg3\Media\domains\x.rootdomain.ru" type="readwrite" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="RXYYDPI-SVKNBMF-YADG7WD"/>
<minDiskFreePct>1</minDiskFreePct>
<versioning/>
<copiers>0</copiers>
<pullers>0</pullers>
<hashers>0</hashers>
<order>random</order>
</folder>
. |
|
|
<device id="RXYYDPI-SVKNBMF-YADG7WD"/> . |
|
|
<folder id="x.rootdomain.ru" label="x.rootdomain.ru" path="c:\rtx_mg3\Media\domains\x.rootdomain.ru" type="readwrite" rescanIntervalS="10" ignorePerms="false" autoNormalize="true">
<device id="RXYYDPI-SVKNBMF-YADG7WD"/>
<minDiskFreePct>1</minDiskFreePct>
<versioning/>
<copiers>0</copiers>
<pullers>0</pullers>
<hashers>0</hashers>
<order>random</order>
</folder>
. |
|
<device id="RXYYDPI-SVKNBMF-YADG7WD"/> <minDiskFreePct>1</minDiskFreePct> <versioning/> <copiers>0</copiers> <pullers>0</pullers> <hashers>0</hashers> <order>random</order> . |
|
|
|
|
|
|
|
|
|
HTML algorithm
Review
-
Search by tag name in double quotes, for example
"br". -
The sequence of tags is formed by the
|separator, for example"html"|"head"|"title". -
Getting one of the same tags is done by adding an index after the tag separator (starting from zero), for example
"html"|"br"|1|"title". -
By default, the transition to the search for the next tag occurs with the selection of the zero tag.
-
The
"html"|0|"head"|0|"title"|0query is equivalent to the"html"|"head"|"title"query, i.e. a query by tag name always returns a list. -
The query can be built using indexes, for example
"0|0|1". -
Parentheses are used to refer to tag attributes.
-
The
"html"|"head"|("charset")request will return a list of parent tags"head"that contain the"charset"attribute. -
The
"html"|"head"|("type="test/css")request will return a list of parent tags"head"in which the"type"attribute is equal to"test/css".
<HTML>
<HEAD>
<META a="1" b="2"/>
</HEAD>
<BODY>
<p id="x1" class="abc">abc abc
<a href="http://asdf.ru">link</a> <br>
</p>
<br><br>
<p id="x2" class="abc" v="123">zxcv zxcv</p>
</BODY>
</HTML>
| Search Query | Function | Result |
|---|---|---|
|
|
<p id="x1" class="abc">abc abc <a href="http://asdf.ru">link</a> <br></p> . |
|
abc abc <a href="http://asdf.ru">link</a> <br> . |
|
|
|
|
|
|
|
|
|
|
|
|
<p id="x1" class="abc">abc abc <a href="http://asdf.ru">link</a> <br></p> . |
|
|
<p id="x1" class="abc">abc abc <a href="http://asdf.ru">link</a> <br></p> . |
|
|
<p id="x2" class="abc" v="123">zxcv zxcv</p> . |
|
|
|
See also
-
Role svc