我正在嘗試創建一個使用Web服務的Android應用程序。我想使用XDocument
來閱讀XML文件。我在我的項目中創建了一個名爲xmlfolder
的文件夾,並將我的XML文件myxml
放入其中。用XDocument讀取xml文件
我嘗試過其他解決方案,例如How to load XML file located inside the folder of the application in window phone 7?,但似乎不起作用。我不斷收到錯誤:
System.IO.DirectoryNotFoundException: Could not find a part of the path "/xmlfolder/myxml.xml"
。
和
myxml.xml myxml is null
這裏是我的嘗試:
if (string.IsNullOrEmpty(myFIileXML))
{
XDocument loadedData = XDocument.Load ("xmlfolder/myxml.xml");
myFileXML = loadedData.ToString();
}
[XDocument讀取具有名稱空間的根元件的XML文件]的可能副本(http://stackoverflow.com/questions/19142606/xdocument-reading-xml-file-with-root-element-having-namespaces) – Monika
你的文件設置爲「content」和「always always」? – MarcinJuraszek
@Monika謝謝你的回覆。但我已經通過這個鏈接,但似乎並沒有解決我的問題。我只是無法找到該文件。 – user3034944