次のようなxmlがあります
<Students xmlns="http://AdapterTest">
<Schema name="Schema1" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
<ElementType name="Student" content="empty" model="closed">
<AttributeType name="Student_id" dt:type="string"/>
<AttributeType name="Student_Name" dt:type="string"/>
<attribute type="Student_id"/>
<attribute type="Student_Name"/>
</ElementType>
</Schema>
<Student Student_id="123456" Student_Name="Udaya" xmlns="x-schema:#Schema1"/>
<Student Student_id="568923" Student_Name="Christie" xmlns="x-schema:#Schema1"/>
<Student Student_id="741852" Student_Name="Test Name" xmlns="x-schema:#Schema1"/>
<Student Student_id="852789" Student_Name="Sample Name" xmlns="x-schema:#Schema1"/>
</Students>
私のアプリケーションでは、次のように LINQ を使用してノードにアクセスしようとしています。
XDocument xdoc1 = XDocument.Load("Customer.xml");
List<Student> studentList =
(from _student in xdoc1.Element("Students").Elements("Student")
select new Student
{
firstName = _student.Attribute("Student_id").Value,
lastName = _student.Attribute("Student_Name").Value,
}).ToList();
オブジェクトのインスタンスに設定されていないオブジェクト参照が返されます。ルート要素から xmlns="http://AdapterTest" を削除すると、正常に動作します。ここに欠けているもの