I am parsing an XML file using code similar to this (I removed things to make it shorter) XmlDocument doc = new XmlDocument(); doc.LoadXml(fileText); XmlNodeList fileLabels = doc.GetElementsByTagName("label"); label.text = fileLabels[0].InnerXml; It works fine, except for its treatment of XML predefined entities. In particular, it parses " and ' correctly, returning " and ', but it does not parse & and > returning & and > instead of and >. Does anyone know what could cause this?
Not really a Unity-specific question, but typically if you have a lot of special characters that you need to parse you should wrap the XmlText in CDATA and access the value with the Value property instead (which might work in your case without the CDATA). Alternately - just serialize your data into a class with a bunch of fields instead of traversing the DOM manually.
That's right. I would also point you towards the XML serialization, instead of doing it manually using the XmlDocument. Just look for the XML Serialization throughout the forum, or Google it. It's a consistent and buletproof way of doing things.