xml_save_nodeΒΆ
xml_save_node saves a UniScript object as an XML file.
-
bool = xml_save_node(oXML, ssFileName)
-
bool = xml_save_node(oXML, ssFileName, nFormatted)
-
ssXML = xml_save_node(oXML, "", nFormatted)
Return Value
bool is TRUE (1), if the function was successful and otherwise FALSE (0).
If ssFileName is an empty string, the function returns the XML code as a sting instead of writing oXML into a file.
Parameters
-
oXML
oXML is a special formatted UniScript object (see Comment).
-
ssFileName
ssFileName is the file name, e.g.
"c:\\test\\text.xml"
.
-
nFormatted
Value Description 0 Output without new line characters. New lines are only added to text elements. (Default) 1 New line characters and indentation with two spaces.
Comment
The object oXML must have the following structure:
oXML = [.
[1] = "text node"
[2] = oXML_other
[N] = ...
attr = [. name=ssValue, ...]
name = "element-name"
]
Example
def test_xml_save_node()
{
o = xml_parse_string("<a att='1'>mixed<b>contents</b><c><d></d></c></a>")
// print o
o[2].name = "i";
// print o
ssFile = GetTempFileName();
xml_save_node(o, ssFile, 1);
s = text_file_read(ssFile);
if (_g().unit_test_cleanup) {
DeleteFile(ssFile);
}
}
test_xml_save_node();
History
Version | Description |
---|---|
R2013.5 | If ssFileName is an empty string, the function returns the XML code as a sting instead of writing oXML into a file. |
5.20 | New. |
See also
id-1241474