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:\test.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(destination)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="jscript">
var xmldoc1 = new ActiveXObject("Msxml2.DOMDocument.4.0");
var xmldoc2 = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmldoc1.load("sample.xml");
xmldoc1.save(xmldoc2.XMLDocument);
</script>
Custom object supporting persistence Any 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; in the IPersistStream case, IPersistStream Load will be called
with an IStream that supports the Read, Seek, and Stat methods.
"Scott Caskey [MSFT]" <scaskey@online.microsoft.com> wrote in message
news:40116800$1@news.microsoft.com...[color=blue]
> To indent using the XmlTextWriter:
>
> XmlTextWriter _writer = new XmlTextWriter(<parameters>);
> _writer.Formatting = Formatting.Indented; (Indicates how the output is
> formatted.)
> _writer.Indentation = 1; (sets how many IndentChars to write for each[/color]
level[color=blue]
> in the hierarchy)
> _writer.IndentChar = "\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[/color]
rights.[color=blue]
> Use of included script samples are subject to the terms specified at
>
http://www.microsoft.com/info/cpyright.htm
>
> "Ot" <uraza@tds.invalid (use net)> wrote in message
> news:%23gmZHJS4DHA.876@TK2MSFTNGP10.phx.gbl...[color=green]
> >
> > "Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
> > news:O8SthSR4DHA.2572@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Ot wrote:
> > >
> > > > I would like to delete each item and the preceding textnode that[/color]
> > contains[color=darkred]
> > > > the alignment text. Any suggestions as to how to do this using DOM[/color][/color]
> and[color=green][color=darkred]
> > > > Xpath?
> > >
> > > Instead reformat XML during Save() operation (using
> > > XmlTextWriter.Formatting property).[/color]
> >
> > I currently have
> >
> > Private doc As FreeThreadedDOMDocument40
> >
> > I load it from an xml file with doc.load("c:\test.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[/color][/color]
want.[color=blue][color=green]
> > 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:\test.xml"). Yes,[/color]
> this[color=green]
> > saves it a lot of times, but the xml file is small, and I want to keep[/color][/color]
the[color=blue][color=green]
> > copy on disk current.
> >
> > It is unclear to me how to use XmlTextWriter... that is, how do I tell[/color][/color]
the[color=blue][color=green]
> > save method to "indent".
> >
> >
> >[/color]
>
>[/color]