0

At present I am using XmlTextWriter with WrieStartElement(), WriteAttributeString(), & WriteEndElement(). Is this the fastest way to create an XML file?

Update: I'm looking at XML writers, not raw string writers. Between characters that need to be escaped, handling namespaces, etc. I have no desire to re-invent the wheel. And I doubt I would be any faster after I take all that into account.

David Thielen
  • 28,723
  • 34
  • 119
  • 193
  • 1
    Suggestion: try a different way of doing it (make sure you do all the escaping of special characters correctly), and measure both. – Michael Kay Sep 14 '14 at 08:46
  • No, writing strings manually is faster. Writing bytes (and not going through Encoding) is even faster – usr Sep 15 '14 at 12:04

1 Answers1

-1

And the answer is no (details here). Use XmlWriter instead. The summation of the linked article is "because Microsoft said XmlWriter is replacing XmlTextWriter.

David Thielen
  • 28,723
  • 34
  • 119
  • 193
  • 2
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Yotam Omer Sep 15 '14 at 22:08
  • Summation added (although Use XmlWriter is an accurate summation). – David Thielen Sep 15 '14 at 22:17
  • 1
    @DavidThielen A summation isn't really the best - any chance you add additional details from the blog post (ie, **why** is Microsoft saying this?)? – admdrew Sep 16 '14 at 19:00