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

阅读: 评论:0

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

关于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;

本文发布于:2024-01-29 05:48:22,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170647850513136.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:多层   使用方法   格式   xml
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23