Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

xmlwrite

Write XML Document Object Model node

Syntax

xmlwrite(filename,DOMnode)
chr = xmlwrite(DOMnode)

Description

xmlwrite(filename,DOMnode) writes the Document Object Model (DOM) node DOMnode to the file filename.

chr = xmlwrite(DOMnode) returns a serialized DOM node as a character vector.

Input Arguments

filename

Character vector that specifies the name of a local file or a URL.

DOMnode

Document Object Model node, as defined by the World Wide Web consortium. For more information, see What Is an XML Document Object Model (DOM)?

Output Arguments

chr

Character vector that contains the serialized DOM node as it appears in an XML file.

Examples

Create and view an XML document:

docNode = com.mathworks.xml.XMLUtils.createDocument... 
    ('root_element')
docRootNode = docNode.getDocumentElement;
docRootNode.setAttribute('attr_name','attr_value');
for i=1:20
    thisElement = docNode.createElement('child_node'); 
    thisElement.appendChild... 
        (docNode.createTextNode(sprintf('%i',i)));
    docRootNode.appendChild(thisElement);
end
docNode.appendChild(docNode.createComment('this is a comment'));

xmlFileName = [tempname,'.xml'];
xmlwrite(xmlFileName,docNode);
type(xmlFileName);

See Also

|

Introduced before R2006a

Was this topic helpful?