为什么我的Datagridview只显示一行应显示多行?

时间:2014-03-27 20:18:31

标签: xml vb.net datagridview

我尝试过导入不同的XML并且工作正常。然而,当我从测试XML转到新的我想要的XML时,它现在只显示1行,至少应该显示超过20个。

xml如下:

<result>
<status>SUCCESS</status>
<version>1</version>
<data_remaining_as_bytes>349367739445</data_remaining_as_bytes>
<data_remaining_as_string>325.37GB</data_remaining_as_string>
<data name="torrents">
<row id="0">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>1003117266</downloaded_as_bytes>
<downloaded_as_string>956.6MB</downloaded_as_string>
<elapsed_as_seconds>15201677</elapsed_as_seconds>
<elapsed_as_string>175d22h41m17s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>925342418</size_as_bytes>
<size_as_string>882.5MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>453892818</uploaded_as_bytes>
<uploaded_as_string>432.9MB</uploaded_as_string>
</row>
<row id="1">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>14610573</elapsed_as_seconds>
<elapsed_as_string>169d2h29m33s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>0.0</percentage_as_decimal>
<percentage_as_string>0.0%25</percentage_as_string>
<size_as_bytes>8511160761</size_as_bytes>
<size_as_string>7.93GB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>0</uploaded_as_bytes>
<uploaded_as_string>0B</uploaded_as_string>
</row>
<row id="2">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>13911587</elapsed_as_seconds>
<elapsed_as_string>161d0h19m47s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>1469765330</size_as_bytes>
<size_as_string>1.37GB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>0</uploaded_as_bytes>
<uploaded_as_string>0B</uploaded_as_string>
</row>
<row id="3">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>13911577</elapsed_as_seconds>
<elapsed_as_string>161d0h19m37s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>741139782</size_as_bytes>
<size_as_string>706.8MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>0</uploaded_as_bytes>
<uploaded_as_string>0B</uploaded_as_string>
</row>
<row id="4">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>13855138</elapsed_as_seconds>
<elapsed_as_string>160d8h38m58s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>739319267</size_as_bytes>
<size_as_string>705.1MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>0</uploaded_as_bytes>
<uploaded_as_string>0B</uploaded_as_string>
</row>
<row id="5">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>9259122688</downloaded_as_bytes>
<downloaded_as_string>8.62GB</downloaded_as_string>
<elapsed_as_seconds>13207246</elapsed_as_seconds>
<elapsed_as_string>152d20h40m46s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>16704814658</size_as_bytes>
<size_as_string>15.56GB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>11549523968</uploaded_as_bytes>
<uploaded_as_string>10.76GB</uploaded_as_string>
</row>
<row id="6">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>345989418</downloaded_as_bytes>
<downloaded_as_string>330MB</downloaded_as_string>
<elapsed_as_seconds>12790178</elapsed_as_seconds>
<elapsed_as_string>148d0h49m38s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>338157866</size_as_bytes>
<size_as_string>322.5MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>540557908</uploaded_as_bytes>
<uploaded_as_string>515.5MB</uploaded_as_string>
</row>
<row id="7">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>540146810</downloaded_as_bytes>
<downloaded_as_string>515.1MB</downloaded_as_string>
<elapsed_as_seconds>12147614</elapsed_as_seconds>
<elapsed_as_string>140d14h20m14s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>247496253</size_as_bytes>
<size_as_string>236MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>373734973</uploaded_as_bytes>
<uploaded_as_string>356.4MB</uploaded_as_string>
</row>
<row id="8">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>12142131</elapsed_as_seconds>
<elapsed_as_string>140d12h48m51s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>339106251</size_as_bytes>
<size_as_string>323.4MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>0</uploaded_as_bytes>
<uploaded_as_string>0B</uploaded_as_string>
</row>
<row id="9">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>348484471</downloaded_as_bytes>
<downloaded_as_string>332.3MB</downloaded_as_string>
<elapsed_as_seconds>11564854</elapsed_as_seconds>
<elapsed_as_string>133d20h27m34s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>338031479</size_as_bytes>
<size_as_string>322.4MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>559084407</uploaded_as_bytes>
<uploaded_as_string>533.2MB</uploaded_as_string>
</row>
<row id="10">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>4207007536</downloaded_as_bytes>
<downloaded_as_string>3.92GB</downloaded_as_string>
<elapsed_as_seconds>11131507</elapsed_as_seconds>
<elapsed_as_string>128d20h5m7s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>4118140720</size_as_bytes>
<size_as_string>3.84GB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>18284544</uploaded_as_bytes>
<uploaded_as_string>17.4MB</uploaded_as_string>
</row>
<row id="11">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>10955515</elapsed_as_seconds>
<elapsed_as_string>126d19h11m55s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>337873046</size_as_bytes>
<size_as_string>322.2MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>0</uploaded_as_bytes>
<uploaded_as_string>0B</uploaded_as_string>
</row>
<row id="12">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>10615484</elapsed_as_seconds>
<elapsed_as_string>122d20h44m44s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>147123999</size_as_bytes>
<size_as_string>140.3MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>223087965</uploaded_as_bytes>
<uploaded_as_string>212.8MB</uploaded_as_string>
</row>
<row id="13">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>10462653</elapsed_as_seconds>
<elapsed_as_string>121d2h17m33s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>197480754</size_as_bytes>
<size_as_string>188.3MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>190152704</uploaded_as_bytes>
<uploaded_as_string>181.3MB</uploaded_as_string>
</row>
<row id="14">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>196150162</downloaded_as_bytes>
<downloaded_as_string>187.1MB</downloaded_as_string>
<elapsed_as_seconds>10258310</elapsed_as_seconds>
<elapsed_as_string>118d17h31m50s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>165888457</size_as_bytes>
<size_as_string>158.2MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>259817472</uploaded_as_bytes>
<uploaded_as_string>247.8MB</uploaded_as_string>
</row>
<row id="15">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>1006930627</downloaded_as_bytes>
<downloaded_as_string>960.3MB</downloaded_as_string>
<elapsed_as_seconds>10014152</elapsed_as_seconds>
<elapsed_as_string>115d21h42m32s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>0.0</percentage_as_decimal>
<percentage_as_string>0.0%25</percentage_as_string>
<size_as_bytes>945081027</size_as_bytes>
<size_as_string>901.3MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>42352640</uploaded_as_bytes>
<uploaded_as_string>40.4MB</uploaded_as_string>
</row>
<row id="16">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>87514500</downloaded_as_bytes>
<downloaded_as_string>83.5MB</downloaded_as_string>
<elapsed_as_seconds>9490483</elapsed_as_seconds>
<elapsed_as_string>109d20h14m43s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>82042244</size_as_bytes>
<size_as_string>78.2MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>123124488</uploaded_as_bytes>
<uploaded_as_string>117.4MB</uploaded_as_string>
</row>
<row id="17">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>9490412</elapsed_as_seconds>
<elapsed_as_string>109d20h13m32s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>182279252</size_as_bytes>
<size_as_string>173.8MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>0</uploaded_as_bytes>
<uploaded_as_string>0B</uploaded_as_string>
</row>
<row id="18">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>9490387</elapsed_as_seconds>
<elapsed_as_string>109d20h13m7s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>142094379</size_as_bytes>
<size_as_string>135.5MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>116760662</uploaded_as_bytes>
<uploaded_as_string>111.4MB</uploaded_as_string>
</row>
<row id="19">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>735526568</downloaded_as_bytes>
<downloaded_as_string>701.5MB</downloaded_as_string>
<elapsed_as_seconds>9422617</elapsed_as_seconds>
<elapsed_as_string>109d1h23m37s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>682213032</size_as_bytes>
<size_as_string>650.6MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>528400384</uploaded_as_bytes>
<uploaded_as_string>503.9MB</uploaded_as_string>
</row>
<row id="20">
<data_rate_in_as_bytes>0</data_rate_in_as_bytes>
<data_rate_in_as_string>0B</data_rate_in_as_string>
<data_rate_out_as_bytes>0</data_rate_out_as_bytes>
<data_rate_out_as_string>0B</data_rate_out_as_string>
<downloaded_as_bytes>0</downloaded_as_bytes>
<downloaded_as_string>0B</downloaded_as_string>
<elapsed_as_seconds>9422599</elapsed_as_seconds>
<elapsed_as_string>109d1h23m19s</elapsed_as_string>
<info_hash>testhash</info_hash>
<label/>
<maximum_ratio_as_decimal>1.5</maximum_ratio_as_decimal>
<maximum_ratio_as_string>150.0%25</maximum_ratio_as_string>
<name>TestName</name>
<percentage_as_decimal>100.0</percentage_as_decimal>
<percentage_as_string>100.0%25</percentage_as_string>
<size_as_bytes>911733011</size_as_bytes>
<size_as_string>869.5MB</size_as_string>
<status>stopped</status>
<uploaded_as_bytes>1389306406</uploaded_as_bytes>
<uploaded_as_string>1.29GB</uploaded_as_string>
</row>
</data>
</result>

导入此数据时未发生XML异常。 VB.net代码

Imports System.Xml
Public Class Form1

    Dim apikey As String

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim rowids As Integer
        Dim webClient As New System.Net.WebClient
        Dim input As String = webClient.DownloadString("https://api.justseed.it/torrents/list.csp?api_key=" & apikey)
        RichTextBox1.Text = input
        Dim doc = XDocument.Parse(input)
        rowids = 1
        Dim ass = doc.Descendants("data_remaining_as_string").First().Value
        Label2.Text = ass
        DataGridView1.Rows(0).Cells(0).Value = "May"
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        apikey = TextBox1.Text
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ReadXMLFile()
    End Sub
    Public Shared Function EmptyStringToNull(o As String) As Object
        Dim ret As Object = DBNull.Value
        Try
            If o.Trim.Length = 0 Then
                ret = DBNull.Value
            Else
                ret = o
            End If
        Catch ex As Exception

        End Try
        Return ret
    End Function
    Private Sub ReadXMLFile()
        Dim xmlDoc As New System.Xml.XmlDocument
        Dim root As XmlElement = Nothing
        Dim nodes As XmlNodeList = Nothing
        Dim node As XmlNode = Nothing
        Dim xmlFile As String = ""
        Try
            OpenFileDialog1.ShowDialog()
            xmlFile = OpenFileDialog1.FileName
            xmlDoc.Load(xmlFile)
            root = xmlDoc.DocumentElement
            nodes = root.SelectNodes("//result/data") 'The XMLPath
            'nodes = root.SelectNodes("//result/data/row") 'The XMLPath
            Me.DataGridView1.Rows.Clear() 'Clear Grid
            For Each node In nodes
                Me.DataGridView1.Rows.Add(EmptyStringToNull(node("row").GetAttribute("id")),
                                          EmptyStringToNull(node("row")("data_rate_in_as_string").InnerText),
                                          EmptyStringToNull(node("row")("data_rate_out_as_string").InnerText),
                                          EmptyStringToNull(node("row")("downloaded_as_string").InnerText),
                                          EmptyStringToNull(node("row")("elapsed_as_string").InnerText))

            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

我无法弄清楚为什么只出现一行。非常感谢帮助。我也会尝试回答您的任何问题。

2 个答案:

答案 0 :(得分:0)

从我可以看到你在这里犯了错误:

nodes = root.SelectNodes("//result/data") 'The XMLPath
'nodes = root.SelectNodes("//result/data/row") 'The XMLPath

这些评论撇号需要改变。所以第二个没有被注释掉。

然后你需要从for循环中的每一行中删除(“row”):

Me.DataGridView1.Rows.Add(EmptyStringToNull(node.GetAttribute("id")),

EmptyStringToNull(node("data_rate_in_as_string").InnerText), etc..

答案 1 :(得分:0)

在IRC聊天中,有一位朋友打电话给Inari。

            For Each node In nodes
            Dim ele As XmlElement = node
            Me.DataGridView1.Rows.Add(EmptyStringToNull(ele.GetAttribute("id")),
                                      EmptyStringToNull(node("data_rate_in_as_string").InnerText),
                                      EmptyStringToNull(node("data_rate_out_as_string").InnerText),
                                      EmptyStringToNull(node("downloaded_as_string").InnerText),
                                      EmptyStringToNull(node("elapsed_as_string").InnerText))
            Next

以下是它的工作原理

<Inari> apparently
<Inari> well you're selecting row elements so theres no node("row") as the node isa already the row

<Inari> node.getAttribute doesnt exist thouhg
<Inari> so i casted it to XmlElement
<Inari> not sure if hteres a better way
<Inari> :P