读xml返回dataset问题

mdh_zl 2008-12-08 11:08:10
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header></env:Header><env:Body><com:locationSearchResponse xmlns:com="com.hrs.soap.hrs"><locationSearchResponse><responseTimeMillis>40</responseTimeMillis><resultCode>0</resultCode><locations><locationName>北京火车站</locationName><locationISO3Language>chn</locationISO3Language><iso3Country>chn</iso3Country><locationId>48979</locationId><poiId>18375</poiId><geoPosition><latitude>39.90289</latitude><longitude>116.4207</longitude></geoPosition></locations><locations><locationName>北京首都国际机场</locationName><locationISO3Language>chn</locationISO3Language><iso3Country>chn</iso3Country><locationId>48979</locationId><poiId>18373</poiId><geoPosition><latitude>40.07941</latitude><longitude>116.58707</longitude></geoPosition></locations><locations><locationName>北京展览馆</locationName><locationISO3Language>chn</locationISO3Language><iso3Country>chn</iso3Country><locationId>48979</locationId><poiId>18374</poiId><geoPosition><latitude>39.93774</latitude><longitude>116.33805</longitude></geoPosition></locations></locationSearchResponse></com:locationSearchResponse></env:Body></env:Envelope>

xml文章是这样的
我想把locations读到dataset中 望大家帮忙
...全文
117 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuxyu 2009-05-06
  • 打赏
  • 举报
回复
我就是用的这个方法,读xml中几十条还可以,但是读一个1千条记录的XML,只读了244条,就不反应了,是不是性能的问题啊?
zhnzzy 2008-12-09
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 pgameli 的回复:]
DataSet.ReadXml(文件名)
DataTable=DataSet.table[0]

这样简单点
[/Quote]

这个就可以,很简单
gongsun 2008-12-09
  • 打赏
  • 举报
回复
没话说了,凑个热闹。
antiking 2008-12-09
  • 打赏
  • 举报
回复
DataSet dsXml = new DataSet(); try
{
dsXml.ReadXml(new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(strXml)));
}
catch (Exception ex)
{
throw new Exception("读取XML出错!");
return;
}
yefengzhixia 2008-12-09
  • 打赏
  • 举报
回复
学习。。
恩 顶了 !! 虽然我不知道为什么。。。。呵呵呵 欢迎加入c#新群 63242231 共同学习
mengxj85 2008-12-08
  • 打赏
  • 举报
回复
System.Data.DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("phonebook.xml"));
gv.DataSource = ds;
gv.DataBind();
HDNGO 2008-12-08
  • 打赏
  • 举报
回复
ReadXml~
jiang_jiajia10 2008-12-08
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 chuxue1342 的回复:]
写个C#的!

C# code
DataSet getds(string path)
{
FileSteam fs=New FileStrea(Server.MapPath(path),FileMode.Open);
XmlDataDocument doc=New XmlDataDocument();
doc.DataSet.ReadXml(New StreamReader(fs));
DataSet ds=New DataSet();
ds=doc.DataSet;
Return ds;
}
[/Quote]
BernardSun 2008-12-08
  • 打赏
  • 举报
回复
DataSet xmlDataSet = new DataSet();
xmlDataSet.ReadXml(Server.MapPath("~/App_Data/locations.xml"));

DataTable dt = xmlDataSet.Tables[0];
wuyq11 2008-12-08
  • 打赏
  • 举报
回复
public static DataSet GetDataSetByXml(string strXmlPath)
{
try
{
DataSet ds = new DataSet();
ds.ReadXml(GetXmlFullPath(strXmlPath));
if(ds.Tables.Count > 0)
{
return ds;
}
return null;
}
catch(Exception)
{
return null;
}
}
chuxue1342 2008-12-08
  • 打赏
  • 举报
回复
写个C#的!

DataSet getds(string path)
{
FileSteam fs=New FileStrea(Server.MapPath(path),FileMode.Open);
XmlDataDocument doc=New XmlDataDocument();
doc.DataSet.ReadXml(New StreamReader(fs));
DataSet ds=New DataSet();
ds=doc.DataSet;
Return ds;
}
pgameli 2008-12-08
  • 打赏
  • 举报
回复
DataSet.ReadXml(文件名)
DataTable=DataSet.table[0]

这样简单点
chuxue1342 2008-12-08
  • 打赏
  • 举报
回复

''' <summary>
''' 根据XML文件返回表
''' </summary>
''' <param name="id"></param>
''' <param name="path"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function getdata(ByVal path As String) As DataView
Dim dt As DataTable = New DataTable()
Dim dv As DataView = New DataView()
Dim stream As FileStream = New FileStream(Server.MapPath(path), FileMode.Open)
Dim doc As XmlDataDocument = New XmlDataDocument
doc.DataSet.ReadXml(New StreamReader(stream))
dt = doc.DataSet.Tables(0)
dv = dt.DefaultView
stream.Close()
Return dv
End Function

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧