[mono-android] XML Read File

Jonathan Pryor jpryor at novell.com
Sun Mar 20 22:02:25 EDT 2011


On Mar 20, 2011, at 12:03 PM, Michael Reynolds wrote:
> How do I convert the following line in Java to use in MonoDroid:
> 
>         XmlResourceParser scores = getResources().getXml(R.xml.myscores);

Unfortunately, you don't. Android XML support (via the e.g. org.xmlpull.v1 and org.xml.sax packages, among others) isn't currently bound.

The workaround is to include "myscores.xml" as a raw resource, by placing it into the file Resources\Raw\myscores.xml, then using Resources.OpenRawResource(int). Alternatively, you could myscores.xml as an Asset (by placing it into the Assets directory and setting the build action to AndroidAsset), then using Assets.Open("myscores.xml").

 - Jon



More information about the Monodroid mailing list