Linq から XML クエリにデータを返すのに問題があります。私は次のXMLを持っています
<sdnList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/sdnList.xsd">
<publshInformation>
<Publish_Date>03/14/2013</Publish_Date>
<Record_Count>5440</Record_Count>
</publshInformation>
</sdnList>
次を使用して公開日の値を取得しようとしています
XDocument xDoc = XDocument.Load(fileName);
XNamespace xNS = "http://tempuri.org/sdnList.xsd";
XNamespace xNS1 = "http://www.w3.org/2001/XMLSchema-instance";
string strCurrentDate = xDoc.Element(xNS1 + sdnList").Element("publshInformation").Element("Publish_Date").Value;
これは、オブジェクトの予期されるエラーを返すだけです。私の問題は名前空間にあることを知っています(そして、おそらく単純な解決策になるでしょう)
ありがとう