Aller au contenu principal

xml_each

Return or loop threw all children of current node.

XML_EACH

NAME

xml_each - Return or loop threw all children of current node.

SYNOPSIS

xml_each(xml:string, [text_node:true|false, error:variable]);

DESCRIPTION

This function return all children of current node as an array.

If use as a callback function, return each node for each loop.

PARAMETERS

xml
Specify xml to parse.
error
Capture error.
text_node
Return text node or not.

RETURN

An array of all children.

MODULES

To use this module, you must specify the following in /usr/local/website/site.conf:

Module xml {
        Library : "/usr/local/lib/libsnxml.so"
        Init : "snxml_init"
}

EXAMPLES

res=<{
        xml=xml_new(error:t,file:"/html/test.xml");
        %include "/includes/xml.sn";
        for l xml_each(xml:xml)
                l.xml_name();
                l.xml_attr();
        endfor

        xml_free(xml);
}>. return res=fn\[{"id":"1"},{"class":"pierre"}\]fn\[{"id":"2"},{"class":"chantal"}\].

res=<{
        xml=xml_new(error:t,file:"/html/test.xml");
        %include "/includes/xml.sn";
        l = xml.xml_each();
        node = l[0];
        node.xml_name();
        node = l[1];
        node.xml_name();
        for i in l do
                i.xml_name();
                i.xml_type();
        endfor;

        xml_free(xml);
}>. return res=fnfnfn1fn1.

SEE ALSO

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

AUTHOR

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

MODIFICATIONS

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

Edit

© 2024 extenso Inc. All rights reserved.