请教一个xml的查询问题
<?xml version= "1.0 " encoding= "UTF-8 "?>
<hulu id= "1000 " name= "1000 ">
<user>
<param name= "userID " value= "001 "/>
<param name= "username " value= "xman "/>
</user>
</hulu>
大家好,想把这个xml 放入 DataGrid中 请问如何操作?
形式为这样的
userid username
001 xman
XmlNodeList nodes = dom.SelectNodes( "hulu/user/param[@name= 'userID ']|hulu/user/param[@name= 'username '] ");
用这个好象放不了两列
急需 谢谢~~~各位`~~
ps:这个问题是朋友提的, 查询出所有是user节点且满足name= 'userID ' 和name= 'username '
------解决方案--------------------只用XPATH似乎没什么办法
------解决方案--------------------不懂 帮顶啊
------解决方案--------------------和我遇到的问题 差不多 ~~~ 晕呐~~~ 我也没解决呐~~~
------解决方案--------------------XmlNodeList nodes = dom.SelectNodes( "hulu/user/param[@name= 'userID ']);
再取遍历nodes ,hulu/user/param[@name= 'username ']
------解决方案--------------------System.Xml.XmlDocument d = new System.Xml.XmlDocument();
d.Load(Server.MapPath( "XMLFile.xml "));
System.Xml.XmlNodeList nodes = d.SelectNodes( "/hulu/user[param/@name= 'userID ' and param/@name= 'username '] ");
foreach(System.Xml.XmlNode node in nodes)
{
Response.Write( " <li> ");
Response.Write(node.ChildNodes[0].Attributes[ "value "].Value);
Response.Write(node.ChildNodes[1].Attributes[ "value "].Value);
}
------解决方案--------------------根据id取hulu/user/param,遍历param,取param的name和value属性