xml ファイルから属性を取得したいと考えています。属性は私のルートにあります。ここに例を見てください:
<PriceList ID="003" xmlns="BLA">
<Items>
<Item ID="AAK0435">
<RetailPrice currency="EUR">1.6</RetailPrice>
</Item>
<Item ID="AAL0144">
<RetailPrice currency="EUR">1470</RetailPrice>
</Item>
</Items>
</PriceList>
ルートの属性「ID」を取得したいと思います。私はこのようなことを試しましたが、彼は foreach ループに入りません。
XPathDocument xPriceDocument = new XPathDocument(priceList.FullName, XmlSpace.None);
XPathNavigator xPriceNavigator = xPriceDocument.CreateNavigator();
foreach (XPathNavigator xPriceListIdNavigator in xPriceNavigator.Select("PriceList"))
{
priceListId = xPriceListIdNavigator.GetAttribute("ID", "");
}