Build Error Windows Store Universal App 10 using XmlDocument

I am using 5.2.1p1 (64 bit) and I tried to build a Windows 10 Universal Project.
The following line of code causes an error:

XmlDocument mResourceDictionary;

string result = mResourceDictionary.SelectSingleNode(“//Resources/String[@ID='” + ID + “']”).InnerText;

The error states

‘System.Xml.XmlDocument’ contains no definition for ‘SelectNodes’ and no extension method ‘SelectNodes’ could be found.

This also happened when building an Universal App for 8.1.
This also happened when trying to use SelectSingleNode.

The code compiles fine in VS 2015 and building standalone (for Windows) and Android worked!

Seems SelectNodes is not implemented in both our WinRTLegacy.dll and isn’t available in .NET Core 5.0, you’ll have to use other methods for selecting node…

If it helps, you can lookup the source for those methods here - Reference Source

Alternatively you could use Xml parsing using using System.Xml.Linq, with XDocument, XNode, etc

Any plans to add that to your our implementation of

  • System.Xml.XmlDocument

http://docs.unity3d.com/Manual/windowsstore-missingtypes.html

Since the source is available :wink:

?

It’s low priority… so I wouldn’t want to raise your hopes…

Rats. That’s the last thing I need to port my code too. I use these methods everywhere and re-writing it all in a different manner is a major PITA. That source you pointed to is great but mostly won’t work as it relies on all sorts of other not available stuff.

So for anyone else coming this way and unfamiliar with XDocument. What I found out so far is that it’s easier to replace XmlDocument with XDocument and then use Element and Elements (as well as potentially Descendants) to replace SelectSingleNode and SelectNodes

So something like:

XDocument xdoc = XDocument.Parse(xmlText);
var singleNode = xdoc.Element("exampleNode");
var listOfNodes = singleNode.Elements("exampleNodes");

foreach (XElement e in listOfNodes)
{
     string exampleAttr = e.Attribute("code").Value;
     string exampleInnerText = e.Value;
}

Instead of using SelectNodes use GetElementByTagName.
Try something like this.

XmlDocument xmlDoc = XmlDocument();

xmlDoc.LoadXml(yourTextFile);

XmlNodeList xnList = xmlDoc.GetElementByTag(childTagName);

Have they added support for XmlDocument to Universal App builds?

Yes, Microsoft brought back XmlDocument to Universal App builds, but I think some pieces are still missing:

  • System.Xml.Schema.* stuff
  • System.Xml.Formatting
  • System.Xml.XmlEntity
  • System.Xml.XmlEntityReference
  • System.Xml.XmlNodeReader
  • System.Xml.XmlNotation
  • System.Xml.XmlOutputMethod
  • System.Xml.XmlResolver
  • System.Xml.XmlTextReader
  • System.Xml.XmlTextWriter
  • System.Xml.XmlTokenizedType
  • System.Xml.XmlUrlResolver
  • System.Xml.XmlValidatingReader

What a delightful thing to discover! bad news for us.

Tomas (or anyone else) are you aware of a decent replacement for SelectSingleNode that actually IS supported? I’m needing to parse a third-party generated XML document, and I’ve got to select nodes deep inside a tree that can only be cleanly identified by children that have children that have unique data stashed inside them.

For example, I’ve been using:
root.SelectSingleNode(“Assets/Conversations/Conversation[Fields/Field[Value='”+conversationName+“']]”)
to grab an XMLElement.

I know that I could use GetElementsByTag to get a list, and then iterate through the list, each time iterating through a list of children, until I find the right identifier, but I might kill myself long before attempting that.

Have you tried using XDocument?

Well… er… no. Despite monark’s post, after a little Googling I got the impression that it wasn’t supported, for some reason.

I take from your question that I made a mistake there… heh. I’ll go back and implement that now, and see what happens.

Thanks Aurimas! The response is very much appreciated.

XDocument is supported, I went to quite a lot of trouble to have some classes that hide the translation between XDocument and XmlDocument (don’t confuse the 2) for cross platform compiling.
If they have brought back support for XmlDocument that would mostly make that redundant now :frowning:
But if you don’t need to be cross platform XDocument is fine and dandy.

Has anyone solved this by now? I’m having trouble using the Graph and Chart Engine by prosourcelabs due to that exact reason…