易截截图软件、单文件、免安装、纯绿色、仅160KB

判断xml的一个节点是否存在 - .NET技术 / VB.NET

我现在要读一个xml文件的一个节点值,但有时候这个节点可能不存在,这个时候我要新建这个节点并给它赋值。
所以问一下 如何判断xml的节点是存在还是不存在?
谢谢大家


不会。net,帮顶

C# code:

System.Xml.XmlNode node = xmlDoc.SelectSingleNode("root/" + key); //key节点
if (node == null){
//不存在
}



引用

C# code

System.Xml.XmlNode node = xmlDoc.SelectSingleNode("root/" + key); //key节点
if (node == null){
//不存在
}


c#的我知道,可是vb.net是怎么表示的?

Assembly code:
Dim node As System.Xml.XmlNode = xmlDoc.SelectSingleNode("root/" & key)
'key节点
If node Is Nothing Then
'不存在
End If


VB.NET code:
Dim node As System.Xml.XmlNode = xmlDoc.SelectSingleNode("root/" & key)
'key节点
If node Is Nothing Then
'不存在
End If


Dim node As System.Xml.XmlNode = xmlDoc.SelectSingleNode("//Root/A[@id=" & id & "]")
If node IsNot Nothing Then
End If

为了问问题,
先的赚赚


相关问答:

vb读取xml - VB / 基础类

现在有个xml文件是<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xm ......

vb操作excel - VB / 基础类

问题:
现在Access数据库中有两张表TableA和TableB
TableA中有记录如下:
字段1(Name) 字段2(Num)
  A 3
  A 4
  B 6
  ... ......

求助:C代码change toVB代码 - VB / 基础类

挺繁琐,之前发的帖子,分值太低现在重发一个。欢迎各位大侠~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[] ......

XML压缩传输 - PowerBuilder / Web 应用

功能说明:Java servlet 把XML数据压缩后发送到PB用户端,PB收到数据后解压出来.
传输要经过Base64编码.
问题是:能收到数据但是解压不出来.想请教大家或者有什么好的办法?
PB可以用"zlibwapi.DLL" 解压
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号