Skip to Main Content Skip to Search
Product Documentation

xmlwrite - Write XML Document Object Model node

Syntax

xmlwrite(filename,DOMnode)
str = xmlwrite(DOMnode)

Description

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

str = xmlwrite(DOMnode) serializes the DOM node to a string.

Input Arguments

filename

String enclosed in single quotation marks 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

str

String 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

xmlread | xslt

How To

Related Links

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS