在C#中解析困难的XML

时间:2013-12-10 14:29:39

标签: c# xml-parsing rows

我必须解析非常糟糕的XML。我想知道是否有人有办法解析它而不必一行一行地在“”之间搜索文本

<?xml version="1.0" encoding="utf-8"?>
<stats>
  <title>Soccer Match 1</title>
  <rows>
    <match>
      <row column1="" column2="Pre Game" />
      <row column1="101" column2="105" />
      <row column1="ARS" column2="MNU" />
      <row column1="0" column2="0" />
      <row column1="0" column2="POSSESSION %" column3="0" />
      <row column1="0 (0)" column2="SHOTS (ON TARGET)" column3="0 (0)" />
      <row column1="0" column2="CORNERS" column3="0" />
      <row column1="0" column2="FOULS" column3="0" />
      <row column1="0/0" column2="YELLOW/RED" column3="0/0" />
    </match>
  </rows>
</stats>

2 个答案:

答案 0 :(得分:3)

对XML有什么不好?我会使用Linq2Xml来解析它 - here is a tutorial on how to do that

答案 1 :(得分:0)

我没有使用Linq2XML,而是使用XmlDocument

相关问题