Go to main content

xmlget

A simple extractor for a XML element

XMLGET

NAME

xmlget - A simple extractor for a XML element

SYNOPSIS

xmlget (xml:"…", elem:"….", [error: var]);

DESCRIPTION

XML stands for extensible markup language. It is human-readable and machine-readable. This function is used to find and extract the value of the element (elem) within the XML. In other words, xmlget allows the user to get the value of an element in a string which is in a XML format. It will return the first element (elem) that it finds within the XML string. No validation is done for the XML. For a more robust implementation, refer to XML functions.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

res={_{xmlget(xml:"test",elem:"id")}}. return res=test.]

In this example, xmlget will extract the value of the elem. Here, its name is
id, and its value is test. Hence, the result will be "test".

res={_{xmlget(xml:"test",elem:"id")}}. return res=test.]

Here, the value contains an attribute with 5 as a value. The name of the elem
is still id, and its value is test. The answer will, again, be "test".

x={_{xmlget(xml:"xxxx|sn_output.res",elem:"OsloID",error:ret); 'ret='; ret;}} return .*errcode=6.*]

In this last example, the program tries to read something that is not in a XML
format. The user gets an errorcode=6, meaning that it is an execution error.

SEE ALSO

{{ include("includes/strings.sn") }}

AUTHOR

Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.