I know I'm missing something. I am not currently using XmlTextWriter nor
XmlTextReader. I am using the methods for DOMDocument40.
The .save method applied to the doc saves it where I want. I can see how
to create an XmlTextWriter. How do I get the doc.save method to use that
writer? doc.save("c:\te st.xml") should be replaced with what? Do I
provide the XmlTextWriter to doc.save? Do I have to loop through my
in-memory xml domdocument40 and call on the XmlTextWriter for each node?
Sorry for the confusion.
The parameter to the save method is described as below.
oXMLDOMDocument .save(destinati on)Parameters
destination
An object. The object can represent a file name, an ASP Response object,
a DOMDocument object, or a custom object that supports persistence.
IXMLDocument Object Duplicates 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.
<script language="jscri pt">
var xmldoc1 = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
var xmldoc2 = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
xmldoc1.load("s ample.xml");
xmldoc1.save(xm ldoc2.XMLDocume nt);
</script>
Custom object supporting persistence Any other custom COM object that
supports QueryInterface for IStream, IPersistStream, or IPersistStreamI nit
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; in the IPersistStream case, IPersistStream Load will be called
with an IStream that supports the Read, Seek, and Stat methods.
"Scott Caskey [MSFT]" <sc*****@online .microsoft.com> wrote in message
news:40******** @news.microsoft .com...
To indent using the XmlTextWriter:
XmlTextWriter _writer = new XmlTextWriter(< parameters>);
_writer.Formatt ing = Formatting.Inde nted; (Indicates how the output is
formatted.)
_writer.Indenta tion = 1; (sets how many IndentChars to write for each
level in the hierarchy)
_writer.IndentC har = "\t"; (sets which character to use for indenting.
<tab> in this case)
...
_writer.Flush() ; (used for saving)
Hope this helps,
Scott
--
This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Ot" <ur***@tds.inva lid (use net)> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
"Oleg Tkachenko" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:O8******** ******@TK2MSFTN GP09.phx.gbl... Ot wrote:
> I would like to delete each item and the preceding textnode that
contains > the alignment text. Any suggestions as to how to do this using DOM and > Xpath?
Instead reformat XML during Save() operation (using
XmlTextWriter.F ormatting property).
I currently have
Private doc As FreeThreadedDOM Document40
I load it from an xml file with doc.load("c:\te st.xml").
The xml, I presume, at this point is stored in memory.
I navigate around using Xpath on the "doc" making such changes as I
want. Presumably these are stored only in memory until I save the doc.
Each time I make a change to the data I doc.save("c:\te st.xml"). Yes,
this saves it a lot of times, but the xml file is small, and I want to keep
the copy on disk current.
It is unclear to me how to use XmlTextWriter.. . that is, how do I tell
the save method to "indent".