   
save()
Is a member of:
|
XMLDOMDocument
|
Syntax
objDOMDocument.save(objTarget)
Remark
The parameter objTarget can be a file name, an ASP response object, an XML document object, or a custom object that supports persistence and specific interfaces.
If you have manipulated the DOMDocument in any way by appending, removing, or whatever, remember that it is not saved to the XML file until you have called the save() method.
The save() method does not return anything; however, if an error is reported, the error can expose one of the return values listed in table .
0.0.1 save() method return values (continued)
Returned
|
Description
|
S_OK
|
Success
|
XML_BAD_ENCODING
|
The document contains a character that does not belong in the specified encoding
|
E_INVALIDARG
|
A string was provided but it is not a valid file name. or an object was provided that does not support any of the above interfaces
|
E_ACCESSDENIED
|
save() operation is not permitted
|
E_OUTOFMEMORY
|
save() cannot allocate buffers
|
Other values
|
Any other file system error
|
Saving in ADO 2.5You may have noticed in previous examples that we tend to save our XML to a file and then load the file into a DOMDocument. In Microsoft ADO 2.5 that ships with Windows 2000, you will be able to save directly to a
DOMDocument.
This is how you will be able to do it:
Dim strSQL As String
Dim adoCon As ADODB.Connection
Dim adoRst As ADODB.Recordset
Dim objDOMDocument As DOMDocument
strSQL = "SELECT * FROM categories"
Set adoCon = New ADODB.Connection
Set adoRst = New ADODB.Recordset
adoCon.ConnectionString = "northwind"
adoCon.CursorLocation = adUseClient
adoCon.Open
Set adoRst.ActiveConnection = adoCon
adoRst.Open strSQL, , adOpenForwardOnly, _
adLockReadOnly, adCmdText
Set objDOMDocument = New DOMDocument
objDOMDocument.async = False
adoRst.Save objDOMDocument, 1 ' save this to DOM
adoRst.Close
adoCon.Close
Set adoCon = Nothing
¬ Prepare ADO objects.
¬ Open database connection.
¬ Get resultset.
¬ Prepare the DOMDocument.
¬ Save the recordset to the DOMDocument.
   
This manuscript is an abridged version of a chapter
from the Manning
Publications book XML
Programming with VB and ASP. This chapter looks at the Microsoft DOM objects. NOTE: Most images have been removed to increase speed and many of the code comments have also been removed for presentation. Please purchase the book to enjoy the full experience of all the chapters with images and code comments!
|