我真的只是想选择列出的值
SOPDetail
TargetInfo
DomesticJurisidiction
每个都是另一个的子节点。当我进行迭代时,我找到了节点 DomesticJurisidiction 但是当我选择使用 xpath 时,我找不到它。有人对为什么有建议吗?
/*XmlNode targetNode = xDoc.SelectSingleNode("/SOPDetail/TargetInfo/DomesticJurisidiction");
string haha = targetNode.InnerXml;*/
foreach (XmlNode xmlNode in xDoc.ChildNodes)
{
Console.WriteLine(xmlNode.Name);
foreach (XmlNode chldNode in xmlNode.ChildNodes)
{
Console.WriteLine(chldNode.Name);
foreach (XmlNode cNode in chldNode.ChildNodes)
{
Console.WriteLine(cNode.Name + ":" + cNode.InnerXml);
}
}
}
就像我提到的 foreach 迭代完美地找到了这个节点,为什么我不能使用 SelectsingleNode 选择它?
<SOPDetail LogId="324" LastModified="2007-05-20T09:20:50" xmlns="http://usop.ctadvantage.com/">
<TargetInfo>
<DomesticJurisdiction>Connecticut</DomesticJurisdiction>
<ServedName>CT Demo Account (All State Corp)</ServedName>
<ServedJurisdiction>New York</ServedJurisdiction>
<NameDiscrepancyExists>false</NameDiscrepancyExists>
<Defendant>Test</Defendant>
</TargetInfo>
<LawsuitInfo>
<ReceiptDate>2007-05-20</ReceiptDate>
<CreatedDate>2007-05-20T08:41:38</CreatedDate>
<MethodOfService>Courier</MethodOfService>
<LawsuitType>Other</LawsuitType>
<LawsuitSubType>Documents requiring hard copy delivery</LawsuitSubType>
<AnswerDate />
<DocumentServed>Acknowledgment of Service</DocumentServed>
<NatureOfAction>
Notifying of Dft. 's No Opposition Summary Judgment Motion and Order
</NatureOfAction>
</LawsuitInfo>
<CaseType>Standard</CaseType>
<Remark />
<CourtInfo>
<Name />
<AddressLine1 />
<AddressLine2 />
<AddressLine3 />
<AddressLine4 />
<City />
<County />
<State />
<Zip />
<Country />
<Phone />
<Fax />
<Email />
</CourtInfo>
<AttorneyInfo>
<Name />
<AddressLine1 />
<AddressLine2 />
<AddressLine3 />
<AddressLine4 />
<City />
<County />
<State />
<Zip />
<Country />
<Phone />
<Fax />
<Email />
<LawFirmName />
</AttorneyInfo>
<AgencyInfo>
<Name />
<AddressLine1 />
<AddressLine2 />
<AddressLine3 />
<AddressLine4 />
<City />
<County />
<State />
<Zip />
<Country />
<Phone />
<Fax />
<Email />
</AgencyInfo>
<CaseInfo>
<CaseNumber />
<Plaintiff />
</CaseInfo>
<DocId>123asdf234</DocId>
</SOPDetail>