[XMLStream] creates a new XML stream from XML data. The tag requires one parameter which is the XML data to be parsed. The return value is an XML stream object which can be manipulated using its member tags to visit each element of the XML data in turn.
[XMLStream] provides an interface to a SAX-like parser so XML data can be examined element by element rather than being read in and parsed all at once.
<?LassoScript
Variable: 'XMLStream' = (XMLStream: ' ... ');
?>
Use the [XMLStream] tag and its member tags. The following example shows how [XMLStream] can be used to parse a simple XML document. The attributes of an HTML anchor tag are shown. Notice that the XML stream first visits the opening tag, then the contents of the tag (including nested tags), and finally the closing tag. [XMLStream->Next] is used to navigate forward through the stream setting the current node to each element of the stream in turn.
[var: 'xml' = '<a href=\'http://www.example.com\'>Example Web Site</a>']
[Output: $xml]
<hr>
[Variable: 'stream' = (XMLStream: $xml)]
[While: $stream->Next]
[Output: 'Node Type: ' + $stream->Nodetype]<br>
[Output: 'Tag Name: ' + $stream->Name]<br>
[Output: 'Tag Prefix: ' + $stream->Prefix]<br>
[Output: 'Tag Local Name: ' + $stream->LocalName]<br>
[Output: 'Tag Depth: ' + $stream->Depth]<br>
[Output: 'Is Empty?: ' + $stream->IsEmptyElement]<br>
[Output: 'Has Value?: ' + $stream->HasValue]<br>
[Output: 'Text Value: ' + $stream->Value]<br>
[Output: 'Has Attributes?: ' + $stream->HasAttribute]<br>
[Output: 'Attribute Count: ' + $stream->AttributeCount]<br>
[Output: 'Get Attribute: ' + $stream->(GetAttribute:'href')]
<hr>
[/While]
<a href='http://www.example.com'>Example Web Site</a>
Node Type: startElement
Tag Name: a
Tag Prefix:
Tag Local Name: a
Tag Depth: 0
Is Empty?: false
Has Value?: false
Text Value:
Has Attributes?: true
Attribute Count: 1
Get Attribute: http://www.example.com
Node Type: text
Tag Name: #text
Tag Prefix:
Tag Local Name: #text
Tag Depth: 1
Is Empty?: false
Has Value?: true
Text Value: Example Web Site
Has Attributes?: false
Attribute Count: 0
Get Attribute:
Node Type: endElement
Tag Name: a
Tag Prefix:
Tag Local Name: a
Tag Depth: 0
Is Empty?: false
Has Value?: false
Text Value:
Has Attributes?: true
Attribute Count: 0
Get Attribute: http://www.example.com
Tag Link | [XMLStream] | Category | XML |
---|---|---|---|
Type | Substitution | Data Source | Any |
Support | Preferred | Version | 7.0 |
Output Type | XMLStream | Security | None |
Implementation | LCAPI | Sets | Lasso 8.5, Lasso 8.0, Lasso 7.0 |
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft