C#中怎样读取xml文件中节点的值

如题所述

第1个回答  2020-02-16
xml;
}
}
private
string
name.sex
=
sex.name)
{
case
"/。;;
}
set
{
name
=
value;"/
/
/你的xml地址
string
id
=
"/
<
}
}
}
}
xml里面的所有信息就是在list集合里面了;/.add(info);
public
string
sex
{
get
{
return
sex;xuliehua\;//100</)
{
foreach
(xmlnode
node1
in
node;/)
{
foreach
(xmlnode
node2
in
node1。;sex>读取xml里面的文件信息
list<。:
sex
=
node2;
}
set
{
id
=
value;dlcl\;//.xml"
foreach
(xmlnode
node
in
xml;
//
list
=
new
list</读取xml文件
xml;field>/name>
<:
name
=
node2,string
sex)
{
this;//abc>.name
==
"/
<mycomputer\field>/id"/name>
string
name
=
"
</。但是道理是一样的。.innertext;id>.id
=
id;
<打印电脑\
/.name
=
name,
sex);c#\
//s2c#\/sex>);
break。
/.childnodes)
{
switch
(node2;男<。;lisi<
break;1<item"//id>sex>sex>。
public
class
information
{
private
string
id;
public
string
id
{
get
{
return
id;//();
}
}
public
information()
{
}
public
information(string
id.innertext;xml文件信息
<
default.childnodes)
{
if
(node1;
<实体类;item>,string
name。
当然你可以做多个表和多个字段属性咯;id>/
this;name":\"
/zhangsan</information>e;
</
case
"item>
}
}
info
=
new
information(id;name>
}
}
//
<item>
public
string
name
{
get
{
return
name;"男</.load(@"
/.childnodes)
{
if
(node;实例化xml
xmldocument
xml
=
new
xmldocument().innertext;
<//:
id
=
node2;name>.name
==
"/。嘿嘿;
<!
xml实际就是一个本地简单的数据库
我只做了一个简单的;;abc>item>/
<。简单吧;
</,
name;2<
string
sex
=
"
this;//很高兴可以给你解答;abc"
}
set
{
sex
=
value;*******下面开始循环读取xml文件信息********/
break;information>
information
info
=
null;id>/;
}
}
private
string
sex;/将信息保存至集合
list;/
第2个回答  2019-12-04
我不喜欢按节点查
所以麻烦点
DataSet
ds
=
DataSet();
ds.ReadXML("文件路径");
string
temp
=
ds.table[0].Rows[0]["Msg"].toString();
相似回答
大家正在搜