我的 XML 具有以下结构:
<?xml version="1.0"?>
<NidanArchiveDS>
<xs:schema id="NidanArchiveDS" targetNamespace="http://tempuri.org/NidanArchiveDS.xsd" xmlns:mstns="http://tempuri.org/NidanArchiveDS.xsd" xmlns="http://tempuri.org/NidanArchiveDS.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="NidanArchiveDS" msdata:IsDataSet="true" msdata:Locale="ru-RU">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Settings">
<xs:complexType>
<xs:attribute name="ContentTypeName" form="unqualified" type="xs:string" use="required" />
<xs:attribute name="ListName" form="unqualified" type="xs:string" use="required" />
<xs:attribute name="DocTypeFieldName" form="unqualified" type="xs:string" />
<xs:attribute name="DocNumberFieldName" form="unqualified" type="xs:string" />
<xs:attribute name="DOcDateFieldName" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Settings" />
<xs:field xpath="@ContentTypeName" />
<xs:field xpath="@ListName" />
</xs:unique>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NidanArchiveDS xmlns="http://tempuri.org/NidanArchiveDS.xsd">
<Settings diffgr:id="Settings1" msdata:rowOrder="0" ContentTypeName="CONTENTTYPE 1" ListName="Заявки на оплату" DocTypeFieldName="Имя11" DocNumberFieldName="Имя22" DOcDateFieldName="Имя33" />
<Settings diffgr:id="Settings2" msdata:rowOrder="1" ContentTypeName="CONTENTTYPE 2" ListName="LST" DocTypeFieldName="Имя44" DocNumberFieldName="Имя" DOcDateFieldName="Имя5555" />
</NidanArchiveDS>
下面是我使用 ContentTypeName="CONTENTTYPE 2" 获取设置的查询
docNameFieldName = (from xn in nidanarchiveSettings.Descendants(System.Xml.Linq.XName.Get("Settings"))
where xn.Attribute(System.Xml.Linq.XName.Get("ContentTypeName")).Value == "CONTENTTYPE 2"
&& xn.Attribute(System.Xml.Linq.XName.Get("ListName")).Value == "LST"
select xn.Attribute(System.Xml.Linq.XName.Get("DocTypeFieldName")).Value).SingleOrDefault();
但它给了我一个空字符串。我想知道如何以正确的样式编写查询以具有此属性。