blob: 5502f9c2ae9ed4ebabac160565f3b73781a5ca85 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001OPTIONAL
2EXPERIMENTAL
3SYNOPSIS
4 #include <xml.h>
5
6 string xml_generate(mixed *xml)
7
Zesstra715ec202025-07-09 22:18:31 +02008DESCRIPTION
9 Converts the given <xml> array into an XML conform string, if
10 possible. The <xml> argument array must have the following structure.
MG Mud User88f12472016-06-24 23:31:02 +020011
Zesstra715ec202025-07-09 22:18:31 +020012 It must contain tag arrays of three elements, with the following
13 indices:
MG Mud User88f12472016-06-24 23:31:02 +020014
15 string XML_TAG_NAME
Zesstra715ec202025-07-09 22:18:31 +020016 The name of the XML tag.
MG Mud User88f12472016-06-24 23:31:02 +020017
18 mapping XML_TAG_ATTRIBUTES
Zesstra715ec202025-07-09 22:18:31 +020019 All attributes given to the XML tag as mapping where the key
20 is the attribute name and the value is its string value.
21
22 If the xml tag does not contain any attributes, this element
23 is set 0:
MG Mud User88f12472016-06-24 23:31:02 +020024
25 mixed * XML_TAG_CONTENTS
Zesstra715ec202025-07-09 22:18:31 +020026 The contents of this xml tag as array. This array may
27 contain either strings, or arrays of sub-tags again with
28 three elements (see example)
MG Mud User88f12472016-06-24 23:31:02 +020029
Zesstra715ec202025-07-09 22:18:31 +020030 If the xml tag does not contain anything, the element is
31 set 0.
MG Mud User88f12472016-06-24 23:31:02 +020032
Zesstra715ec202025-07-09 22:18:31 +020033 In case the parameter does not follow these rules, errors are raised.
34 The method returns a valid XML string otherwise.
35
36 The function is available only if the driver is compiled with Iksemel
37 support. In that case, __XML_DOM__ is defined.
MG Mud User88f12472016-06-24 23:31:02 +020038
Zesstrad59c3892019-11-28 20:53:39 +010039
Zesstra715ec202025-07-09 22:18:31 +020040EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020041 xml_generate(({ "abc", 0, 0 })) -> "<abc/>"
42 xml_generate(({ "abc", ([ "xyz" : "cde" ]), 0 })) -> "<abc xyz="cde"/>"
43
Zesstra715ec202025-07-09 22:18:31 +020044 mixed *xml = ({ "book"
45 , ([ "language" : "common" ])
46 , ({ ({ "title"
MG Mud User88f12472016-06-24 23:31:02 +020047 , 0
Zesstra715ec202025-07-09 22:18:31 +020048 , ({ "This is a title" })
MG Mud User88f12472016-06-24 23:31:02 +020049 })
Zesstra715ec202025-07-09 22:18:31 +020050 , ({ "chapter"
MG Mud User88f12472016-06-24 23:31:02 +020051 , 0
Zesstra715ec202025-07-09 22:18:31 +020052 , ({ "This is a chapter" })
MG Mud User88f12472016-06-24 23:31:02 +020053 })
Zesstra715ec202025-07-09 22:18:31 +020054 , ({ "chapter"
MG Mud User88f12472016-06-24 23:31:02 +020055 , 0
Zesstra715ec202025-07-09 22:18:31 +020056 , ({ "We want "
MG Mud User88f12472016-06-24 23:31:02 +020057 , ({ "b"
58 , 0
Zesstra715ec202025-07-09 22:18:31 +020059 , ({ "bold" })
MG Mud User88f12472016-06-24 23:31:02 +020060 })
Zesstra715ec202025-07-09 22:18:31 +020061 , "here"
MG Mud User88f12472016-06-24 23:31:02 +020062 })
63 })
64 })
65 })
66
67 xml_generate(xml)
Zesstra715ec202025-07-09 22:18:31 +020068 -> "<book language="common"><title>This is the title</title>"
69 "<chapter>This is a chapter</chapter><chapter>We want "
70 "<b>bold</b> here.</chapter></book>"
MG Mud User88f12472016-06-24 23:31:02 +020071
Zesstra715ec202025-07-09 22:18:31 +020072HISTORY
73 Added in LDMud 3.3.718.
MG Mud User88f12472016-06-24 23:31:02 +020074
Zesstra715ec202025-07-09 22:18:31 +020075SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020076 xml_parse(E)