![]() |
|||
|
|||
Usage |
Data can be extracted from a text string and assigned to variables by using the _parse command. |
||
The _parse command takes two arguments, text (the data being parsed) and pattern (against which the text will be matched). Each argument may be either an attribute or a sub-element, and where one argument is presented as an attribute the other may be presented as simple sub-content (i.e. without enclosing tags) because there is no ambiguity. |
|||
The pattern comprises a series of strings (groups of characters which are expected in the incoming text) separated by interpolations (which define the target element or attribute to which parsed data items are to be assigned. The _parse command matches each string in turn to the incoming text. All characters in the text which fall between these matched strings are assigned to the interpolation which is described at this point in the pattern. |
|||
Note that carriage returns and linefeeds are treated as meaningful characters, whether they occur in text or pattern. Note also that, because a UNIX newline is only a single character and a DOS newline is two characters, a newline appearing in a UNIX pattern will not match a newline appearing in a text file which was created under DOS. |
|||
To parse repeated text, such as delimited variables, use a _for loop and pass the rump of each parsing back for re-parsing with each repeat of the loop. An example of this is included below. |
|||
The most common problem with the _parse command is mistakenly adding newline or carriage return characters either to the incoming text or to the pattern definition. The pattern definition starts immediately after its host opening tag, so be careful not to start the pattern on a new line unless you want the pattern to start by matching a carriage return. |
|||
Examples | |||
Version |
1.0 |
||
Ref |
t.23 |
||
Date |
28 July 1999 |
||
XML Script homepage | Documentation home | XML Script docs | Command list | Function list | X-Tract docs X-Stream, X-Tract and XML Script are trade marks of DecisionSoft Limited© Copyright 1998-2000 DecisionSoft Limited |