次のような XML ファイルがあります。
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://www.someurl.com/somefile.xslt"?>
<AutoInsuranceClaim xmlns="http://www.someurl.com/schemas/AutoInsuranceClaim">
<Identification>
<BaseOwner>3</BaseOwner>
<BaseType>ABC123</BaseType>
<BaseTypeRef>471038341757</BaseTypeRef>
</Identification>
</AutoInsuranceClaim>
識別ノードを読み取ろうとしています。これが私のコードです:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"..\..\Data.xml");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("ns", "http://www.someurl.com/schemas/AutoInsuranceClaim");
XmlNodeList nodeList = xmlDoc.SelectNodes(@"/ns:AutoInsuranceClaim/Identification", nsmgr);
Console.WriteLine("There are {0} nodes...", nodeList.Count);
少なくとも 1 つの値を取得する必要があることはわかっています。.NET XML 解析に関する私の理解では、プレフィックスのない既定の名前空間がある場合は、独自の名前空間を作成する必要があります。しかし、これは 1 を返すはずでした。
そうでない場合、何が欠けていますか?