c# - XPathEvaluate behave differently in other environments -


I am working on a game in unity and want to parse one file in unity script, from my file line Starts

   

And I want to get the map width attribute,

My code is:

  var mapWidth = ((IEnumerable) tiledMapXmlRoot XPathEvaluate ("/ @ width")) Cast & lt; XAttribute & gt; (). Select (a => Int32.Parse (a.Value)). first ();  

which is working correctly while testing in Visual Studio, but fails when it runs in Integration Script, while debugging I can see it fails Because XPathEvaluate returns an empty collection System.Xml.Xpath.SimpleSlashIterator

While returning to the Visual Studio type System. Xml.Xpath.XPathEvaluator.EvaluateIterator and it is a collection with an element in the expected form

How is it possible to work differently in two environments for the same code? I looked at the version of System.Xml.Linq and viewed it in Visual Studio 4.0.0.0 while in Unity (monodevelop script editor) it is 3.5.0.0, but seeing the library documentation the code should still work

< / Div>

/ @ width should be returned regardless of your source document, this document node Selects the width attribute (which is called "root node" in XPath 1.0), and in the document node Vendors are not any XPath processor that which gives results for the expression of non-Knforment. The correct expression is / * / @ width , which gives the width attribute of the outermost element in the document.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -