How can I load a xml file that not in Assets folder with System.Xml?

I loaded a xml file using XmlDocument:

string filepath = Application.dataPath + "/my.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filepath);

it works fine when I put the “my.xml” in Assets folder, but when I put the “my.xml” to C:\ and chang the code to :

string filepath = "C:/my.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filepath);

it won’t work. and when I debug these code, the monodevelop won’t debug the rest of code after debug “xmlDoc.Load(filepath);”

Did I do something wrong? how can I load a xml file that not in Assets folder?

to what point you can only access stuff in assets, resources or in your persistent data path after build.

Hi cmc,
Thanks for reply. but I can load and play movie which not in Assets folder using AVPro windows media pulgin, it’s because the pulgin make this happen or it just has no path limit for video?

Haha that seems bizarre :stuck_out_tongue:

Do you get any errors or is it just that MonoDevelop stops debugging? By stops debugging, do you mean it detaches or do you mean that it hangs the application etc?

The only thing I can think is that XMLDocument can’t load from C:/ because it doesn’t have administrator access, does it work if you put it in My Documents?

Hi Jamster,
Thanks for reply. Yeah, it’s weird. The MonoDevelop just goes to another break point in another file after this line:
“xmlDoc.Load(filepath);”
It neither goes to the next break point at next line nor throw an error.

I tried another folder, same problem…

I fixed it… and the problem turns out to be “You can only have a single node element at the root of your document”… check this out:

Hi Jamster,
there is an error shown in Editor but it got replaced by another irrelevant error quickly so I didn’t see it. when I move the code to a new project, I finally saw the error. Sorry to make you confused.

Thank you all. :smile:

1 Like