获取XML的某个部分的元素值

时间:2014-09-05 17:18:38

标签: xml xmlreader

我的XmlReader遍历XML,寻找我正在寻找的特定元素。问题是我需要的一个元素存在于XML的两个不同区域。我对此尝试的需求是从j:RegisterActionDescriptionText部分获取<RecordDocketingMessage xmlns="urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:RecordDocketingMessage-4.0">值,而不是从XML的<CoreFilingMessage xmlns="urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:CoreFilingMessage-4.0">部分获取。

XML示例:

  <FilingLeadDocument s:id="DOC00001" s:metadata="# Pages=2">
    <nc:DocumentApplicationName>application/pdf</nc:DocumentApplicationName>
    <nc:DocumentDescriptionText s:id="Notices">Civil Coversheet</nc:DocumentDescriptionText>
    <nc:DocumentFileControlID s:id="FileInputId">101</nc:DocumentFileControlID>
    <nc:DocumentFileControlID s:id="Rule6PublicAnswer">-1</nc:DocumentFileControlID>
    <nc:DocumentFileControlID s:id="Rule6ConfidentialAnswer">-1</nc:DocumentFileControlID>
    <nc:DocumentFileControlID s:id="TypeOfConfidentialDocument">-1</nc:DocumentFileControlID>
    <nc:DocumentPostDate>
      <nc:DateTime>2014-09-02T13:30:51.373476-04:00</nc:DateTime>
    </nc:DocumentPostDate>
    <nc:DocumentReceivedDate>
      <nc:DateTime>2014-09-02T13:30:54.813-04:00</nc:DateTime>
    </nc:DocumentReceivedDate>
    <nc:DocumentSequenceID>1</nc:DocumentSequenceID>
    <ecf:DocumentMetadata>
      <j:RegisterActionDescriptionText s:id="63196854">6721      </j:RegisterActionDescriptionText>
      <ecf:FilingPartyID>
        <nc:IdentificationID>49372</nc:IdentificationID>
        <nc:IdentificationCategoryText>FLEPORTAL</nc:IdentificationCategoryText>
      </ecf:FilingPartyID>
      <ecf:SpecialHandlingInstructions />
    </ecf:DocumentMetadata>
    <ecf:DocumentRendition>
      <ecf:DocumentRenditionMetadata>
        <nc:DocumentApplicationName>application/pdf</nc:DocumentApplicationName>
        <nc:DocumentFileControlID>CCS.pdf</nc:DocumentFileControlID>
        <ecf:DocumentAttachment s:id="ATT00001">
          <nc:BinaryBase64Object>Removed for security purposes</nc:BinaryBase64Object>
          <nc:BinarySizeValue>97426</nc:BinarySizeValue>
          <ecf:AttachmentSequenceID>1</ecf:AttachmentSequenceID>
        </ecf:DocumentAttachment>
      </ecf:DocumentRenditionMetadata>
    </ecf:DocumentRendition>
  </FilingLeadDocument>
  <FilingConnectedDocument s:id="DOC00002" s:metadata="# Pages=1">
    <nc:DocumentApplicationName>application/pdf</nc:DocumentApplicationName>
    <nc:DocumentDescriptionText s:id="Other">Mortgage Claim Amount Worksheet</nc:DocumentDescriptionText>
    <nc:DocumentFileControlID s:id="FileInputId">102</nc:DocumentFileControlID>
    <nc:DocumentFileControlID s:id="Rule6PublicAnswer">-1</nc:DocumentFileControlID>
    <nc:DocumentFileControlID s:id="Rule6ConfidentialAnswer">-1</nc:DocumentFileControlID>
    <nc:DocumentFileControlID s:id="TypeOfConfidentialDocument">-1</nc:DocumentFileControlID>
    <nc:DocumentPostDate>
      <nc:DateTime>2014-09-02T13:30:51.373476-04:00</nc:DateTime>
    </nc:DocumentPostDate>
    <nc:DocumentReceivedDate>
      <nc:DateTime>2014-09-02T13:30:54.813-04:00</nc:DateTime>
    </nc:DocumentReceivedDate>
    <nc:DocumentSequenceID>2</nc:DocumentSequenceID>
    <ecf:DocumentMetadata>
      <j:RegisterActionDescriptionText s:id="63196975">1417      </j:RegisterActionDescriptionText>
      <ecf:FilingPartyID>
        <nc:IdentificationID>49372</nc:IdentificationID>
        <nc:IdentificationCategoryText>FLEPORTAL</nc:IdentificationCategoryText>
      </ecf:FilingPartyID>
    </ecf:DocumentMetadata>
    <ecf:DocumentRendition>
      <ecf:DocumentRenditionMetadata>
        <nc:DocumentApplicationName>application/pdf</nc:DocumentApplicationName>
        <nc:DocumentFileControlID>VRP.pdf</nc:DocumentFileControlID>
        <ecf:DocumentAttachment s:id="ATT00002">
         <nc:BinaryBase64Object>Removed for security purposes</nc:BinaryBase64Object>
         <nc:BinarySizeValue>61900</nc:BinarySizeValue>
          <ecf:AttachmentSequenceID>2</ecf:AttachmentSequenceID>
        </ecf:DocumentAttachment>
      </ecf:DocumentRenditionMetadata>
    </ecf:DocumentRendition>
  </FilingConnectedDocument>



<ecf:ReviewedLeadDocument s:id="REVIEWEDDOC00001">
    <nc:DocumentFiledDate>
      <nc:DateTime>2014-09-03T00:00:00</nc:DateTime>
    </nc:DocumentFiledDate>
    <nc:DocumentPostDate>
      <nc:DateTime>2014-09-02T13:30:51.373</nc:DateTime>
    </nc:DocumentPostDate>
    <nc:DocumentReceivedDate>
      <nc:DateTime>2014-09-02T13:30:54.813</nc:DateTime>
    </nc:DocumentReceivedDate>
    <nc:DocumentSequenceID>1</nc:DocumentSequenceID>
    <nc:DocumentStatus>
      <nc:StatusText>ACCEPTED</nc:StatusText>
    </nc:DocumentStatus>
    <ecf:DocumentMetadata>
      <j:RegisterActionDescriptionText s:id="63196854">5583</j:RegisterActionDescriptionText>
      <ecf:ParentDocumentReference s:ref="DOC00001" />
    </ecf:DocumentMetadata>
    <ecf:DocumentRendition>
      <ecf:DocumentRenditionMetadata s:metadata="2" />
    </ecf:DocumentRendition>
  </ecf:ReviewedLeadDocument>
  <ecf:ReviewedConnectedDocument s:id="REVIEWEDDOC00002">
    <nc:DocumentFiledDate>
      <nc:DateTime>2014-09-03T00:00:00</nc:DateTime>
    </nc:DocumentFiledDate>
    <nc:DocumentPostDate>
      <nc:DateTime>2014-09-02T13:30:51.373</nc:DateTime>
    </nc:DocumentPostDate>
    <nc:DocumentReceivedDate>
      <nc:DateTime>2014-09-02T13:30:54.813</nc:DateTime>
    </nc:DocumentReceivedDate>
    <nc:DocumentSequenceID>2</nc:DocumentSequenceID>
    <nc:DocumentStatus>
      <nc:StatusText>ACCEPTED</nc:StatusText>
    </nc:DocumentStatus>
    <ecf:DocumentMetadata>
      <j:RegisterActionDescriptionText s:id="63196975">10177</j:RegisterActionDescriptionText>
      <ecf:ParentDocumentReference s:ref="DOC00002" />
    </ecf:DocumentMetadata>
    <ecf:DocumentRendition>
      <ecf:DocumentRenditionMetadata s:metadata="1" />
    </ecf:DocumentRendition>
  </ecf:ReviewedConnectedDocument>

当前代码:

if (xr.NodeType == XmlNodeType.Element && xr.Name == "j:RegisterActionDescriptionText")
  {
   eventCode = xr.ReadElementString();
    if (eventCode != null)
     {
      lbEventCode.Items.Add(eventCode);
     }
   }

0 个答案:

没有答案