Click to return to the XML (Extensible Markup Language) home page    
XMLDOMDocument resolveExt...     XMLDOMDocument url Proper...     XMLDOMDocument Object    
Web Workshop  |  XML (Extensible Markup Language)

save Method


Saves an XML document to the specified location.

Syntax

objXMLDOMDocument.save(objTarget);

Parameters

objTarget
Object. The object can represent a file name, an ASP Response object, an XMLDOMDocument object, or a custom object that supports persistence. For more information, see the Remarks below.

Remarks

The behavior differs based on the object specified by the  objTarget parameter.

ObjectDescription
String Specifies the file name. Note that this must be a file name, rather than a URL. The file is created if necessary and the contents are entirely replaced with the contents of the saved document. This mode is not intended for use from a secure client such as Internet Explorer. For example:
    dim xmldoc
    set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
    xmldoc.load("c:\myfile.xml")
    xmldoc.save(Server.MapPath("sample.xml"))
ASP Response ObjectSends the document back to the client that invoked the ASP script. For example:
    dim xmldoc
    set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
    xmldoc.load(Server.MapPath("sample.xml"))
    xmldoc.save(Response)
XML Document ObjectDuplicates the original document. It is the equivalent of saving the document and reparsing it. The document goes through full persistence through XML markup, thereby testing the persistability of your XML document. For example:
    <script language="jscript">
        var xmldoc1 = CreateObject("Microsoft.XMLDOM");
        var xmldoc2 = CreateObject("Microsoft.XMLDOM");
        xmldoc1.load("sample.xml");
        xmldoc1.save(xmldoc2.XMLDocument);
    </script>
Custom Object supporting persistenceAny other custom COM object that supports QueryInterface for IStream, IPersistStream, or IPersistStreamInit can also be provided here and the document will be saved accordingly. In the IStream case, the IStream Write method will be called as it saves the document, and in the IPersistStream case, IPersistStream Load will be called with an IStream that supports the Read, Seek, and Stat methods.

External entity references in DOCTYPE, ENTITY, NOTATION, and xml namespace declarations are not changed; they point to the original document. A saved XML document might not load if the URLs are not accessible from the location in which you saved the document.

Character encoding is based on the encoding attribute in the xml declaration, such as <?xml version="1.0" encoding="windows-1252"?>. When no encoding attribute is specified, the default setting is UTF-8.

Validation is not performed during save, which can result in an invalid document that does not load again because of a specified DTD.

This member is an extension of the W3C DOM.

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
XMLDOMDocument


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.