xml读取

用什么方法把下面一段xml 里FieldName属性读出来

 

<BookMapping xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" BookName="ServiceRewards" DatabaseName="CDIPOptimizationSample">
  <SheetMappingList>
    <SheetMapping SheetName="数据表单" TableName="table1" SampleRows="0">
      <CloumnMappingList>
        <CloumnMapping CloumnName="单板名称" FieldName="ProjectName" AllowNull="true" />
        <CloumnMapping CloumnName="所在产品" FieldName="PrintVersion" AllowNull="true" />
        <CloumnMapping CloumnName="开发代表(RDPDT)" FieldName="RDPDT" AllowNull="true" />
        <CloumnMapping CloumnName="HQA" FieldName="HQA" AllowNull="true" />
        <CloumnMapping CloumnName="绝对规模(初始估计)" FieldName="pla-ext01" AllowNull="true" />
        <CloumnMapping CloumnName="等效新增规模(初始估计)" FieldName="Npla-ext02" AllowNull="true" />

    </CloumnMappingList>
    </SheetMapping>
  </SheetMappingList>
</BookMapping>


慕哥9229398
浏览 391回答 2
2回答

暮色呼如

如果你使用 Linq,你甚至可以用 XML to Linq 的方式写。代码如下。var elements = doc.Root.Element("SheetMappingList").Element("SheetMapping").Element("CloumnMappingList").Elements("CloumnMapping");foreach (var element in elements){ &nbsp; &nbsp;Console.WriteLine(element.Attribute("FieldName").Value);}
打开App,查看更多内容
随时随地看视频慕课网APP