System.XML on XAMARIN forms project

醉酒当歌 提交于 2020-04-30 04:21:46

问题


I am trying to use XmlDocument class ** and **XmlDocument .Load(..) function on the Portable Project of XAMARIN.Forms Portable solution with visual studio community.

The compiler says that "The type or namespace name 'XmlDocument' could not be found (are you missing a using directive or an assembly reference?"

If i go in References it don't allow me to add the System.XML namespace (there is no) and if i browse file and go to system.xml.dll it says me that the file could not be added because this component is already automatically referenced by build system.

what i can to do to use the class??

NOTE: in .Droid and .IOS project there is a referenc to System.xml and in those projects I can use XmlDocument class.


回答1:


PCL doesn't support XmlDocument. You can use System.Xml.Linq.XDocument instead.




回答2:


The XmlDocument class is not available for use in a PCL library, as you can see on its documentation page under Version Information. (Compare to the Version Information section of the XmlDictionary class - notice how this class has Portable Class Library available while XmlDocument does not.)

If you want to use an XmlDocument, you'll have to create a dependency service and implement it separately under both Android and iOS versions.



来源:https://stackoverflow.com/questions/32888478/system-xml-on-xamarin-forms-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!