1

SSIS / C# を使用した XML ファイルの解析

Trailer からレコード数を取得し、 body から TIN を取得し、変数またはどこかに一時的に格納するなどの操作 (提案をお願いします) をさらに処理します。テーブルに保存したくありません。

以下のサンプル xml を見つけてください。

<ACOParticipantData xmlns:xsi="">
  <Header>
    <HeaderCode>HDR_PFPRVDR</HeaderCode>
    <FileCreationDate>20160101</FileCreationDate>
    <ACOProgCode>21</ACOProgCode>
  </Header>
  <Participants>
    <Participant>
      <ACO_ID>V199</ACO_ID>
      <TIN>123456789</TIN>
      <Old_TIN>987654321</Old_TIN>
      <Org_NPI>1234567890</Org_NPI>
      <Ind_NPI>1234567890</Ind_NPI>
      <CCN>123456</CCN>
      <PRG_Eff_Dt>20160101</PRG_Eff_Dt>
      <PRG_Term_Dt>20161231</PRG_Term_Dt>
    </Participant>
  </Participants>
  <Trailer>
    <TrailerCode>TRL_PFPRVDR</TrailerCode>
    <FileCreationDate>20160101</FileCreationDate>
    <RecordCount>1</RecordCount>
  </Trailer>
</ACOParticipantData>
4

2 に答える 2

1

Participants最初にリストを取得してから、すべての参加者の錫番号を次のようにリストに取得する必要があります

ここでは、デモンストレーション用のコンソール アプリを作成しました。

class Program
{
    static void Main(string[] args)
    {
        XDocument doc = XDocument.Load(@"Path to your xml file");

        List<long> tinList = new List<long>();

        tinList = doc.Descendants("Participants").Elements().Elements("TIN").Select(x => (long)x).ToList();

        foreach (long tin in tinList)
        {
            Console.WriteLine(tin);
        }

        Console.ReadLine();
    }
}

出力: (2 人の参加者の場合)

ここに画像の説明を入力

于 2018-11-19T13:48:15.757 に答える