I’m working on an WinRT App and I should ready some XML with a namespace in it. Now this was ok with the old .NET, but now there is no XmlDocument.NameTable anymore. So how can I create an XmlNamespaceManager?
var XmlDoc = new XmlDocument();
XmlDoc.Load(new FileStream("XMLFile1.xml",FileMode.Open,FileAccess.Read));
var nsm = new XmlNamespaceManager(XmlDoc.NameTable);
nsm.AddNamespace("s", "http://api.facebook.com/1.0/");
It’s much easier to handle namespaces with LINQ to XML, which I believe is what you can use in Windows 8:
Read a good LINQ to XML introduction or tutorial, and you should see how to handle namespaces – but it really is significantly simpler than with
XmlDocument. You simply don’t need namespace managers any more! (There may be some cases where they’re still useful – I’m not sure – but I certainly can’t remember using them myself with LINQ to XML.)