我正在尝试编写一个嵌套查询,因为我正在使用的 XML 文档有多个子元素。我需要访问 document-id 属性为“docdb”的值。我需要访问 document-id 属性为“epodoc”的值。
我的类 case_ 定义如下:
public class case_
{
public string appNumber { get; set; }
public string appDate { get; set; }
}
这是我到目前为止所拥有的:
var myCase = from theCases in allCasesXML.Descendants("exchange-document")
select new case_
{
appNumber = (string)theCases.Element("bibliographic-data").Element("application-reference").Element("document-id").Element("doc-number"),
appDate = (from p in theCases.Descendants("document-id")
where (string)theCases.Element("bibliographic-data").Element("application-reference").Element("document-id").Attribute("document-id-type") == "epodoc"
select (p.Element("date").Value)),
};
foreach (var case_ in myCase)
{
System.Windows.Forms.MessageBox.Show(case_.appDate.ToString());
}
我正在使用的 XML 如下:
<exchange-document system="ops.epo.org" family-id="8487663" country="EP" doc- number="0173444" kind="A1">
<bibliographic-data>
<publication-reference>
<document-id document-id-type="docdb">
<country>EP</country>
<doc-number>0173444</doc-number>
<kind>A1</kind>
<date>19860305</date>
</document-id>
<document-id document-id-type="epodoc">
<doc-number>EP0173444</doc-number>
<date>19860305</date>
</document-id>
</publication-reference>
<classification-ipc>
<text>B27M3/06</text>
</classification-ipc>
<classifications-ipcr>
<classification-ipcr sequence="1">
<text>B27M 1/ 04 A I </text>
</classification-ipcr>
<classification-ipcr sequence="2">
<text>B27M 3/ 04 A I </text>
</classification-ipcr>
<classification-ipcr sequence="3">
<text>B44C 3/ 12 A I </text>
</classification-ipcr>
</classifications-ipcr>
<patent-classifications>
<patent-classification sequence="1">
<classification-scheme office="" scheme="CPC" />
<section>B</section>
<class>44</class>
<subclass>C</subclass>
<main-group>3</main-group>
<subgroup>12</subgroup>
<classification-value>I</classification-value>
</patent-classification>
<patent-classification sequence="2">
<classification-scheme office="" scheme="CPC" />
<section>B</section>
<class>27</class>
<subclass>M</subclass>
<main-group>1</main-group>
<subgroup>04</subgroup>
<classification-value>I</classification-value>
</patent-classification>
<patent-classification sequence="3">
<classification-scheme office="" scheme="CPC" />
<section>B</section>
<class>27</class>
<subclass>M</subclass>
<main-group>3</main-group>
<subgroup>04</subgroup>
<classification-value>I</classification-value>
</patent-classification>
</patent-classifications>
<application-reference doc-id="16601238">
<document-id document-id-type="docdb">
<country>EP</country>
<doc-number>85305178</doc-number>
<kind>A</kind>
</document-id>
<document-id document-id-type="epodoc">
<doc-number>EP19850305178</doc-number>
<date>19850719</date>
</document-id>
<document-id document-id-type="original">
<doc-number>85305178</doc-number>
</document-id>
</application-reference>
我似乎无法得到我的查询但是带回任何结果。