xml read 的求助,先拜托,拜托,再拜托。
<?xml version="1.0" encoding="utf-8"?>
<chart_data caption="CHFJPY - 1 Hour">
<bar date="2008/05/28" time="11:00:00" open="100.81" high="100.89" low="100.70" close="100.81"/>
<bar date="2008/05/28" time="12:00:00" open="100.81" high="100.84" low="100.73" close="100.77"/>
<bar date="2008/05/28" time="13:00:00" open="100.77" high="100.86" low="100.70" close="100.78"/>
<bar date="2008/05/28" time="14:00:00" open="100.78" high="100.83" low="100.73" close="100.81"/>
<bar date="2008/05/28" time="15:00:00" open="100.81" high="100.92" low="100.76" close="100.92"/>
<bar date="2008/05/28" time="16:00:00" open="100.92" high="100.92" low="100.80" close="100.82"/>
<bar date="2008/05/28" time="17:00:00" open="100.82" high="100.91" low="100.80" close="100.87"/>
<bar date="2008/05/28" time="18:00:00" open="100.87" high="100.94" low="100.81" close="100.90"/>
<bar date="2008/05/28" time="19:00:00" open="100.90" high="100.95" low="100.85" close="100.86"/>
<bar date="2008/05/28" time="20:00:00" open="100.86" high="100.97" low="100.85" close="100.97"/>
<bar date="2008/05/28" time="21:00:00" open="100.97" high="101.02" low="100.89" close="101.00"/>
<bar date="2008/05/28" time="22:00:00" open="101.00" high="101.01" low="100.94" close="101.00"/>
</chart_data>
xml文件如上,我用了很多办法都无法读出来 `date="2008/05/28" time="11:00:00" open="100.81" high="100.89" low="100.70" close="100.81" 这几条数据。我的办法如下:
XmlTextReader reader = null;
try
{
reader = new XmlTextReader(@"D:\222.xml");
while (reader.Read())
{
Console.WriteLine(reader.Name);
Console.WriteLine(reader.Value);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
reader.Close();
}
只能读取到:
xml
version="1.0" encoding="utf-8"
chart_data
bar
bar
bar
bar
bar
bar
bar
bar
bar
bar
bar
bar
chart_data