Search code examples
c#xmlwindows-8linq-to-xmlxmldocument

Why XmlDocument is using in Windows8 engine?


I guess that XmlDocument is deprecated class and we have to use XDocument instead. But TileUpdateManager.GetTemplateContent from Windows 8 UX core return XmlDocument class. As soon as it is new API, I'm wondering what reason for using XmlDocument here?


Solution

  • (I am using XDocument to refer to Linq2XML & XmlDocument to the System.XML api's)

    Reasons I can see:

    1. XDocument requires LINQ, which is .NET specific. Windows Store apps can be built in JavaScript too, so if you were to build a XDocument to work across both JavaScript & .NET then you would need to port LINQ too and now the engineering task is massive.
    2. XDocument works with XML in a functional way, which is very not standard - the standard way to work with XML is via a DOM model. So XmlDocument provides the way that is more aligned with the way it works elsewhere.
    3. I am guessing you are thinking they are separate API's - when XDocument builds on top of the normal XmlReader classes. So unless you completely rewrote XmlDocument you would always need it - and what is the value of rewriting something that works well just so you can hide it inside something else in the new version.
    4. While a lot of cleanup & improvements have been done to the new API's has been done, remember it is still built on top of COM & a lot of the built in Windows API we currently have (this abstraction means should that change in the future it doesn't impact us, but currently it is not talking direct to the kernel), so likely they are leveraging the existing tools & libraries under the covers - which would all be DOM based and better aligned to XmlDocument.