1. <legend id='VVVWG'><style id='VVVWG'><dir id='VVVWG'><q id='VVVWG'></q></dir></style></legend>

      1. <tfoot id='VVVWG'></tfoot>
      2. <small id='VVVWG'></small><noframes id='VVVWG'>

          <bdo id='VVVWG'></bdo><ul id='VVVWG'></ul>

        <i id='VVVWG'><tr id='VVVWG'><dt id='VVVWG'><q id='VVVWG'><span id='VVVWG'><b id='VVVWG'><form id='VVVWG'><ins id='VVVWG'></ins><ul id='VVVWG'></ul><sub id='VVVWG'></sub></form><legend id='VVVWG'></legend><bdo id='VVVWG'><pre id='VVVWG'><center id='VVVWG'></center></pre></bdo></b><th id='VVVWG'></th></span></q></dt></tr></i><div id='VVVWG'><tfoot id='VVVWG'></tfoot><dl id='VVVWG'><fieldset id='VVVWG'></fieldset></dl></div>

        将 XML 文件读取为 DataSet

        时间:2023-08-28

          • <tfoot id='PonpU'></tfoot>
              <bdo id='PonpU'></bdo><ul id='PonpU'></ul>

                <small id='PonpU'></small><noframes id='PonpU'>

                <legend id='PonpU'><style id='PonpU'><dir id='PonpU'><q id='PonpU'></q></dir></style></legend>
                  <tbody id='PonpU'></tbody>

                  <i id='PonpU'><tr id='PonpU'><dt id='PonpU'><q id='PonpU'><span id='PonpU'><b id='PonpU'><form id='PonpU'><ins id='PonpU'></ins><ul id='PonpU'></ul><sub id='PonpU'></sub></form><legend id='PonpU'></legend><bdo id='PonpU'><pre id='PonpU'><center id='PonpU'></center></pre></bdo></b><th id='PonpU'></th></span></q></dt></tr></i><div id='PonpU'><tfoot id='PonpU'></tfoot><dl id='PonpU'><fieldset id='PonpU'></fieldset></dl></div>
                • 本文介绍了将 XML 文件读取为 DataSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我对解析 XML 文件没有经验,我正在将折线图数据保存到 xml 文件中,所以我做了一些研究.根据 this文章,在所有读取 XML 文件的方法中,DataSet 是最快的.我使用 DataSet 是有道理的,因为可能存在大量数据.这是我的图表文档的外观:

                  I am inexperienced with parsing XML files, and I am saving line graph data to an xml file, so I did a little bit of research. According to this article, out of all the ways to read an XML file, DataSet is the fastest. And it makes sense that I use DataSet since there could be a significant amount of data. Here's how my graph documents look:

                  <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
                  <BreezyCalc>
                      <Graph Version="3.0" Mode="static">
                          <Range>
                              <X Min="-20" Max="20" />
                              <Y Min="-20" Max="20" />
                          </Range>
                          <Lines>
                              <Line Name="MyLine1" R="0" G="255" B="0">
                                  <Point X="-17" Y="9" />
                                  <Point X="7" Y="-5" />
                                  <Point X="10" Y="4" />
                                  <Point X="-6" Y="2" />
                              </Line>
                              <Line Name="MyLine2" R="255" G="0" B="0">
                                  <Point X="-7" Y="3" />
                                  <Point X="8" Y="-1" />
                                  <Point X="-4" Y="-4" />
                                  <Point X="-1" Y="6" />
                              </Line>
                          </Lines>
                      </Graph>
                  </BreezyCalc>
                  

                  由于这些线中可能存在大量点,因此我需要以尽可能少的资源尽快获取数据.如果有比 DataSet 更快的方法,请赐教.否则,有人可以告诉我如何使用 DataSet 作为我的 XML 解析器来获取我的图形数据吗?

                  Since there could be a large number of points in these lines, I need to get the data as quickly and with as little resources as possible. If there is a faster approach than DataSet, please enlighten me. Otherwise, could someone show me how I would get my graph data using a DataSet as my XML parser?

                  推荐答案

                  如果要使用DataSet,很简单.

                  If you want to use a DataSet, it is very simple.

                  // Here your xml file
                  string xmlFile = "Data.xml";
                  
                  DataSet dataSet = new DataSet();
                  dataSet.ReadXml(xmlFile, XmlReadMode.InferSchema);
                  
                  // Then display informations to test
                  foreach (DataTable table in dataSet.Tables)
                  {
                      Console.WriteLine(table);
                      for (int i = 0; i < table.Columns.Count; ++i)
                          Console.Write("	" + table.Columns[i].ColumnName.Substring(0, Math.Min(6, table.Columns[i].ColumnName.Length)));
                      Console.WriteLine();
                      foreach (var row in table.AsEnumerable())
                      {
                          for (int i = 0; i < table.Columns.Count; ++i)
                          {
                              Console.Write("	" + row[i]);
                          }
                          Console.WriteLine();
                      }
                  }
                  

                  如果您想要更快的速度,您可以尝试使用 XmlReader 逐行读取.但是开发难度有点大.你可以在这里看到它:http://msdn.microsoft.com/library/cc189056(v=vs.95).aspx

                  If you want something faster, you can try with XmlReader which read line after line. But it is a bit more difficult to develop. You can see it here : http://msdn.microsoft.com/library/cc189056(v=vs.95).aspx

                  这篇关于将 XML 文件读取为 DataSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 C#,我们如何从 XML Schema 文件中提取属性值 下一篇:使用 HTMLAgilityPack 仅提取页面文本

                  相关文章

                  最新文章

                  <i id='H3gT2'><tr id='H3gT2'><dt id='H3gT2'><q id='H3gT2'><span id='H3gT2'><b id='H3gT2'><form id='H3gT2'><ins id='H3gT2'></ins><ul id='H3gT2'></ul><sub id='H3gT2'></sub></form><legend id='H3gT2'></legend><bdo id='H3gT2'><pre id='H3gT2'><center id='H3gT2'></center></pre></bdo></b><th id='H3gT2'></th></span></q></dt></tr></i><div id='H3gT2'><tfoot id='H3gT2'></tfoot><dl id='H3gT2'><fieldset id='H3gT2'></fieldset></dl></div>

                • <small id='H3gT2'></small><noframes id='H3gT2'>

                  <legend id='H3gT2'><style id='H3gT2'><dir id='H3gT2'><q id='H3gT2'></q></dir></style></legend>

                      • <bdo id='H3gT2'></bdo><ul id='H3gT2'></ul>
                    1. <tfoot id='H3gT2'></tfoot>