Je voudrais obtenir un attribut de mon fichier xml. L'attribut est sur ma racine. Voir ici un exemple:Comment puis-je obtenir un attribut de la racine dans un fichier xml avec XPathNavigator?
<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>
Je voudrais obtenir l'attribut "ID" à la racine. J'ai essayé quelque chose comme ça, mais il ne vient pas dans la boucle foreach.
XPathDocument xPriceDocument = new XPathDocument(priceList.FullName, XmlSpace.None);
XPathNavigator xPriceNavigator = xPriceDocument.CreateNavigator();
foreach (XPathNavigator xPriceListIdNavigator in xPriceNavigator.Select("PriceList"))
{
priceListId = xPriceListIdNavigator.GetAttribute("ID", "");
}