I am working on a game in unity and want to parse an XML file in a unity script, my file starts with the line
<map version="1.0" orientation="orthogonal" width="16" height="12" tilewidth="64" tileheight="64">
and I want to get the map width attribute,
my code is :
var mapWidth = ((IEnumerable)tiledMapXmlRoot.XPathEvaluate("/@width")).Cast<XAttribute>().Select(a => Int32.Parse(a.Value)).First();
which is working right when I test it in visual studio, but fail when it runs in a unity script, while debugging I can see it fails because XPathEvaluate returns an empty collection of type System.Xml.XPath.SimpleSlashIterator
while in visual studio the returned type is System.Xml.XPath.XPathEvaluator.EvaluateIterator and it is a collection with one element as expected
how is it possible for the same code to work differently in two environments ? I looked at the version of System.Xml.Linq and in visual studio its 4.0.0.0 while in unity (monodevelop script editor) it is 3.5.0.0 but looking at the library documentation the code should still work