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
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;
}
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.
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
But if you don’t need to be cross platform XDocument is fine and dandy.