XML Parser on MonoTouch?
I want to parse XML formatted st开发者_运维知识库ring. How to use XML parser on MonoTouch?
Exactly the same way you would in standard C#.
Your options include:
XmlSerializer - good if you want to translate a full document to a set of C# objects
XmlDocument - good if the document is custom beyond XmlSerializer can handle
XPath - good for pulling out small pieces of data, if you don't care about the whole doc.
Linq2XML - another option using Linq.
Depending on what exactly you need.
You can use LINQ to XML in MonoTouch.
So,
var element = XElement.Parse("<cat>dog</cat>");
Console.WriteLine(element.Value);
prints "dog".
You can´t use System.Xml.Linq in full, there will be a JIT part that will blow up when testing in the device, see Xamarin Monotouch limitations:
link
精彩评论