关于c#中解析xml格式多层级使用方法

在针对xml有多层级时候会遇到数据集解析时候处理麻烦解析方法也不知道时候可以参考如下方法人

入参如下:

<Report_Result>
  <Report_Info>
    <ext_lab_code>kingmed</ext_lab_code>
    <lis_Barcode>15112121</lis_Barcode>
    <ext_Barcode>XACS220330</ext_Barcode>
    <ext_checkItem />
    <pat_name>啊倒萨打算啊</pat_name>
    <pat_age />
    <pat_height />
    <pat_wight />
    <pat_pre_week />
    <pat_id>1555</pat_id>
    <pat_bedNo />
    <result_info>
      <result_seq>1</result_seq>
      <ext_compound_item>00.02428</ext_compound_item>
      <ext_compound_name>血项(含网织红计数)</ext_compound_name>
      <ext_combine_code>ZH00061</ext_combine_code>
    </result_info>
    <result_info>
      <result_seq>2</result_seq>
      <ext_compound_item>00.02428</ext_compound_item>
      <ext_compound_name>项(含网织红计数)</ext_compound_name>
      <ext_combine_code>ZH00 </ext_combine_code>
    </result_info>

XmlDocument xmldoc = new XmlDocument();
 xmldoc.LoadXml(richTextBox1.Text);//获取xml     
  XmlNodeList topM = xmldoc.SelectNodes("Report_Result/Report_Info/result_info");//解析集合
            foreach (XmlElement element in topM)
            {
                string id = element.GetElementsByTagName("result_unit")[0].InnerText;//具体入参
                string domainName = element.GetElementsByTagName("result_department")[0].InnerText;//具体入参

            
            }

关于需要引用的类如下所示

using System.Xml;
using System.IO;
using System.Collections;


版权声明:本文为qq_24275649原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。