Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ldmud/doc/efun/xml_generate
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76 lines (60 sloc)
2.52 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OPTIONAL | |
EXPERIMENTAL | |
SYNOPSIS | |
#include <xml.h> | |
string xml_generate(mixed *xml) | |
DESCRIPTION | |
Converts the given <xml> array into an XML conform string, if | |
possible. The <xml> argument array must have the following structure. | |
It must contain tag arrays of three elements, with the following | |
indices: | |
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. | |
In case the parameter does not follow these rules, errors are raised. | |
The method returns a valid XML string otherwise. | |
The function is available only if the driver is compiled with Iksemel | |
support. In that case, __XML_DOM__ is defined. | |
EXAMPLES | |
xml_generate(({ "abc", 0, 0 })) -> "<abc/>" | |
xml_generate(({ "abc", ([ "xyz" : "cde" ]), 0 })) -> "<abc xyz="cde"/>" | |
mixed *xml = ({ "book" | |
, ([ "language" : "common" ]) | |
, ({ ({ "title" | |
, 0 | |
, ({ "This is a title" }) | |
}) | |
, ({ "chapter" | |
, 0 | |
, ({ "This is a chapter" }) | |
}) | |
, ({ "chapter" | |
, 0 | |
, ({ "We want " | |
, ({ "b" | |
, 0 | |
, ({ "bold" }) | |
}) | |
, "here" | |
}) | |
}) | |
}) | |
}) | |
xml_generate(xml) | |
-> "<book language="common"><title>This is the title</title>" | |
"<chapter>This is a chapter</chapter><chapter>We want " | |
"<b>bold</b> here.</chapter></book>" | |
HISTORY | |
Added in LDMud 3.3.718. | |
SEE ALSO | |
xml_parse(E) |