0

我有一个这样的 XML;

<?xml version="1.0" standalone="yes"?>
<Claim.Submission>
  <Header>
    <SenderID>DHA123</SenderID>
    <ReceiverID>A002</ReceiverID>
    <TransactionDate>2012-07-05T15:00:00+05:30</TransactionDate>
    <RecordCount>3</RecordCount>
    <DispositionFlag>PRODUCTION</DispositionFlag>
  </Header>
  <Claim>
    <ID>123</ID>
    <MemberID>m01254</MemberID>
    <PayerID>A002</PayerID>
    <ProviderID>DHA123</ProviderID>
    <EmiratesIDNumber>111-1111-1111111-1</EmiratesIDNumber>
    <Gross>100</Gross>
    <PatientShare>0</PatientShare>
    <Net>100</Net>
  </Claim>
 </Claim.Submission>

但我想在<Claim>节点中动态添加一个数据表。IE; 我想要 XML 作为

<?xml version="1.0" standalone="yes"?>
<Claim.Submission>
  <Header>
    <SenderID>DHA123</SenderID>
    <ReceiverID>A002</ReceiverID>
    <TransactionDate>2012-07-05T15:00:00+05:30</TransactionDate>
    <RecordCount>3</RecordCount>
    <DispositionFlag>PRODUCTION</DispositionFlag>
  </Header>
  <Claim>
    <ID>123</ID>
    <MemberID>m01254</MemberID>
    <PayerID>A002</PayerID>
    <ProviderID>DHA123</ProviderID>
    <EmiratesIDNumber>111-1111-1111111-1</EmiratesIDNumber>
    <Gross>100</Gross>
    <PatientShare>0</PatientShare>
    <Net>100</Net>
  <Encounter>
    <FacilityID>DHA123</FacilityID>
    <Type>3</Type>
    <PatientID>1245</PatientID>
    <Start>2012-01-01T12:00:00+05:30</Start>
    <End>2012-01-05T15:00:00+05:30</End>
    <StartType>1</StartType>
    <EndType>1</EndType>
  </Encounter>
 </Claim>
</Claim.Submission>
4

1 回答 1

0

您可以尝试使用 XmlTextWriter 类写入 XML 文件:

http://msdn.microsoft.com/en-us/library/system.xml.xmltextwriter.aspx

如果您将写入现有文件,它将用您指定的内容替换文件内容,因此请确保正确更新记录,否则您可能会丢失存储的信息。

于 2013-01-29T05:55:24.727 回答