I am looking at these these two classes in C#: XmlTextWriter
and XmlWriter
.
Can anyone explain the difference and tell me where to use which?
What is the difference between XmlTextWriter and XmlWriter?
Asked Answered
XmlWriter
is an abstract class.
XmlTextWriter
is a specific implementation of XmlWriter
.
You should always call XmlWriter.Create
.
MSDN says:
In the .NET Framework version 2.0 release, the recommended practice is to create XmlWriter instances using the XmlWriter.Create method and the XmlWriterSettings class. This allows you to take full advantage of all the new features introduced in this release. For more information, see Creating XML Writers.
"You should always call XmlWriter.Create" why do you make this assertion ? –
Galliett
@Steve: Because Microsoft does. –
Fumigate
Too bad
XmlWriter
and XmlWriterSettings
miss a QuoteChar
property which XmlTextWriter
has, rendering them useless if you require (for whatever reasons) 'single-quoted' attributes instead of the "double-quoted" ones. –
Unhandled © 2022 - 2024 — McMap. All rights reserved.
XmlWriter
. – AleydisCreate()
method which creates an instance. Doesn't that count? – Fixitynew XmlWriter
because it's abstract. – AleydisXmlWriter.Create(stream, settings)
right now and it gives me anXmlWriter
. It's also described exactly to do so in the docs: msdn.microsoft.com/en-us/library/ms162617%28v=vs.110%29.aspx – FixityGetType()
on that instance return? – AleydisXmlWellFormedWriter
. You get the point. – Fixity