Writing XML Tree Documents

A quick and easy way to write an XML document (or any JadeXMLNode object) is by using the writeToString and writeToFile methods. You can override the default indentation and end-of-line sequence by using the JadeXMLDocument class indentString and endOfLine properties.

The following example parses a simple document string and formats the print output.

write1();
vars
    doc : JadeXMLDocument;
begin
    create doc;
    doc.indentString := '    ';
    doc.parseString('<name><first>John</first><last>Smith</last></name>');
    write doc.writeToString;
    delete doc;
end;

The output from the write1 method shown in the previous example is as follows.

<?xml version="1.0"?>
<name>
    <first>John</first>
    <last>Smith</last>
</name>