[英]Read xml data file into Windows.Data.Xml.Dom.XMLDocument
我們如何將xml數據文件讀取到Windows.Data.Xml.Dom.XMlDocument
? 以下代碼僅適用於System.Xml.XmlDocument
。
XmlDocument myxml = XmlDocument.Load("abc.xml");
我將xml文件的內容讀取為字符串,然后使用LoadXml()
:
string fileContent;
StorageFile tileTemplateFile =
await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"<path to file>"));
using (StreamReader reader =
new StreamReader(await tileTemplateFile.OpenStreamForReadAsync()))
{
fileContent = await reader.ReadToEndAsync();
}
XmlDocument tileXml = new XmlDocument();
tileXml.LoadXml(fileContent);
我從這個答案中得到了大部分代碼。
您需要執行以下操作。
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(<string representation of your xml>);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.