XmlDocDump Procedure

Creates an XML document either in memory or in an external file from an XML DOM.

Usage

XmlDocDump, document_id, buffer 

Input Parameters

document_id—Newly created or modified XML document.

buffer—A string containing the file path of an XML file to be written or an output variable name for representing XML data.

Keywords

File—If present, the XML data is written to a file.

Format—An integer specifying the format for indenting the output document. Valid values are 0, 1, and 2 with 0 being the default. The formatting performed for these values is:

0—No formatting

1—Indent the document child nodes

2—Indent all elements

Msvalidate—An integer value that, when present and nonzero, causes XmlDocDump to omit the <!DOCTYPE> XML tag from the output document. Including this XML tag prevents Microsoft Visual Studio from validating the XML document. However, the <!DOCTYPE> XML tag must be included in the output document for non-Microsoft XML validation. Msvalidate is disabled by default.

Discussion

XmlDocDump is used to create an actual XML document from a DOM representation in memory. Typical uses would be to parse and modify an XML document and dump the results to a new XML document, or to create an XML DOM from scratch using XmlNewDoc, XmlNewNode, and XmlAddNode and when finished dump it to an XML document.

Example

This example creates an XML document from scratch and outputs it to an XML file.

; Create a new document.
new_doc = XmlNewDoc('Chart')
; Create a new node
title_node = XmlNewNode('ChartTitle')
; Add the sub tree to the root of the tree.
new_node_id = XmlAddNode(new_doc, title_node, /Doc_id)
; Create a new node.
att_node = XmlNewNode('Attribute', Content=' PV-WAVE Plot')
; Set an attribute of a node.
result = XmlSetAttr(att_node, 'name', Attr_value='Title')
; Createc the sub tree with the two newly created nodes.
subtree = XmlAddNode(title_node, att_node)
; Output the XML data to a file.
XmlDocDump, new_doc, 'new.xml', /File, Format=1
; The new.xml file has the following content:
; <?xml version='1.0'?>
; <!DOCTYPE Chart>
; <Chart>
; <ChartTitle>
; <Attribute name='Title'> PV-WAVE Plot</Attribute>
; </ChartTitle>
; </Chart>