Dokumentation zu: xml_parse(E)

HR Image


OPTIONAL
EXPERIMENTAL
SYNOPSIS
        #include <xml.h>

        mixed * xml_parse(string xml)

DESCRIPTION
        Parses the given string <xml> as a XML conform string. The string must
        have only one root tag, subsequent root tags are ignored.

        If the xml string is correct, an array is of three elements is 
        returned, where as the following indices are defined:

            string XML_TAG_NAME
                The name of the XML tag.

            mapping XML_TAG_ATTRIBUTES
                All attributes given to the XML tag as mapping where the key
                is the attribute name and the value is its string value. 

                If the xml tag does not contain any attributes, this element
                is set 0.

            mixed * XML_TAG_CONTENTS
                The contents of this xml tag as array. This array may 
                contain either strings, or arrays of sub-tags again with 
                three elements (see example)

                If the xml tag does not contain anything, the element is
                set 0.

        If the XML string is not well formed, or there is not enough memory to 
        parse the whole XML structure into the array an error is raised.

        The function is available only if the driver is compiled with Iksemel
        support. In that case, __XML_DOM__ is defined. 


EXAMPLES
        xml_parse("<abc/>")           -> ({ "abc", 0, 0 })
        xml_parse("<abc xyz="cde"/>") -> ({ "abc", ([ "xyz" : "cde" ]), 0 })

        xml_parse("<book language="common">" + 
                  "    <title>This is the title</title>" + 
                  "    <chapter>This is a chapter</chapter>" + 
                  "    <chapter>We want <b>bold</b> here.</chapter>" +
                  "</book>")

            -> ({ "book"
                , ([ "language" : "common" ])
                , ({ ({ "title"
                      , 0
                      , ({ "This is a title" })
                     })
                   , ({ "chapter"
                      , 0
                      , ({ "This is a chapter" })
                     })
                   , ({ "chapter"
                      , 0
                      , ({ "We want "
                         , ({ "b"
                            , 0 
                            , ({ "bold" })
                           })
                         , "here"
                        })
                     })
                  })
               })

HISTORY
        Added in LDMud 3.3.718.

SEE ALSO
        xml_generate(E)

Die Seite ist auch in Deutsch vorhanden.

Start » Magierhandbuch » Docu » Efun » Xml_parse Letzte Generierung: 25.04.2021, 01:58
Email an: mud@wl.mud.de
Valid HTML 4.01!