1
0
Fork 0

what I do best: cosmetics

This commit is contained in:
mfranz 2007-07-01 18:54:32 +00:00
parent faf9ea862d
commit 54c28ced16

View file

@ -72,15 +72,17 @@ var readxml = func(file, prefix = "___") {
return parsexml(file, start, end, data) == nil ? nil : tree; return parsexml(file, start, end, data) == nil ? nil : tree;
} }
# Writes a property tree as returned by readxml() to a file. Chidren # Writes a property tree as returned by readxml() to a file. Children
# with name starting with <prefix> are again turned into attributes of # with name starting with <prefix> are again turned into attributes of
# their parent. <node> must contain exactly one child, which will # their parent. <node> must contain exactly one child, which will
# become the XML file's outmost element. # become the XML file's outermost element.
# #
var writexml = func(file, node, indent = "\t", prefix = "___") { var writexml = func(file, node, indent = "\t", prefix = "___") {
var root = node.getChildren(); var root = node.getChildren();
if(!size(root)) die("writexml(): tree doesn't have a root node"); if(!size(root))
if(substr(file, -4) != ".xml") file ~= ".xml"; die("writexml(): tree doesn't have a root node");
if(substr(file, -4) != ".xml")
file ~= ".xml";
var fh = open(file, "w"); var fh = open(file, "w");
var pre = size(prefix); var pre = size(prefix);
write(fh, "<?xml version=\"1.0\"?>\n\n"); write(fh, "<?xml version=\"1.0\"?>\n\n");
@ -108,7 +110,8 @@ var writexml = func(file, node, indent = "\t", prefix = "___") {
} }
writenode(root[0]); writenode(root[0]);
close(fh); close(fh);
if(size(root) != 1) die("writexml(): tree has more than one root node"); if(size(root) != 1)
die("writexml(): tree has more than one root node");
} }