我正在尝试查询 XMLDocument 并收到错误:
var query = from date in xmlDoc.Root.Elements("Serial")
错误大约是Root
.
我的完整代码如下所示:
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
StorageFile xmlFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("Content1.xml");
XmlDocument xmlDoc;
xmlDoc = await XmlDocument.LoadFromFileAsync(xmlFile);
System.Xml.Linq.XDocument duc = System.Xml.Linq.XDocument.Parse(xmlDoc.GetXml());
var query = from Date in xmlDoc.Root.Elements("Serial")
where Date.Attribute("No").Value == "1";
}
如何访问对象的Root
属性XmlDocument
?