XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load(your.xml");
//get first element
XmlElement xmlRoot=xmlDoc.DocumentElement;
XmlNode node=xmlRoot.SelectSingleNode("//bb[id='xxxx']");
XmlNode n=node.SelectSingleNode("//filepath");
this.txtOut.Text=n.InnerText.ToString();
xmlDoc.Load(your.xml");
//get first element
XmlElement xmlRoot=xmlDoc.DocumentElement;
XmlNode node=xmlRoot.SelectSingleNode("//bb[id='xxxx']");
XmlNode n=node.SelectSingleNode("//filepath");
this.txtOut.Text=n.InnerText.ToString();
解决方案 »
- FckEditor编辑器在使用时有'就会报错
- 【求助】关于时间控制的问题,5秒后执行某个操作,求大神!
- GridView中绑定值得问题
- 关于插入GridView的数据到数据库问题
- |zyciis| 用Response.Write() 这种方法输出的Excel如何来定义他的单无格大小和字段颜色 谢谢
- 求助:ASP如果读取ASP.NET所生成的Cookie
- .net 中如何把数据库的值赋给javascript中的数组
- 请问session的问题
- 孟子大哥请进!
- designmode下web.config的读取问题
- datagrid消失了!
- MS 提出的解决asp与asp.net共享session的文章。与大家分享。
<a1>ddd</a1>
<a2>jjj</a2>
....
<filepath>...</filepath>
</aa><bb>
...
</b><bb>
<id>xxxx</id>
<filepath>xxxxx</filepath>
...
</bb>xml是这样的,楼上写的不行,只能得到<aa>中的filepath
改为
XmlNode n=node.SelectSingleNode("filepath");
..
<id>
<filepath>xxx</filepath>
</id></bb>
XmlNode n=node.SelectSingleNode("filepath");
试了也不行~
<root>
<aa>
<a1>ddd</a1>
<a2>jjj</a2>
<filepath>tmd</filepath>
</aa>
<bb>
<id>xxxx</id>
<filepath>xxxxx</filepath>
</bb>
<bb>
<id>www</id>
<filepath>xxwwwxx</filepath>
</bb>
</root>
<root>
<aa>
<a1>ddd</a1>
<a2>jjj</a2>
<filepath>tmd</filepath>
</aa>
<bb id=xxxx>
<filepath>xxxxx</filepath>
</bb>
<bb id=www>
<filepath>xxwwwxx</filepath>
</bb>
</root>
1、 通过SelectNodes方法获得所有名称为ID的接点。
2、 找出其值为xxxx 的接点(需要自己写,一个循环判断);
3、 获得找到接点的父接点。
4、 读取字节点filePath的值。
can understand?
XmlNode nd1=ndP.NextSibling;
XmlNode curNode = nd.parentnode.selectsingleNode("filepath");
string strNeed = curNode.nodeValue;