易截截图软件、单文件、免安装、纯绿色、仅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 - VB / 基础类

我想把word另存为xml之后,用vb读取这个xml的内容,请问如何实现?
dim f as integer
dim b() as byte
dim s as string
dim L as long
f=freefile()
open "abc.xml" for binary access read as #f
......

遍历一个xml并输出指定节点的值 - .NET技术 / C#

我有一个类似的xml的 string,想通过遍历怎么个xml 输出我想要的element的值
xml 为:
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
  <RequestType>DISCOVER_XML_ME ......

vb读取xml - VB / 基础类

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

求助:C代码改写成VB代码 - VB / 基础类

谁能帮我把下面这些代码改成VB形式的,多谢了,急用~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[],float g ......

VB如何获得别的程序上的表格内容? - VB / API

我的要求是:通过抓取别的程序上的表格的句柄,然后读取这个表格的内容。
表格句柄(类名:MSFlexGridWndClass)我已抓到,接下来如何读取表格的内容就不会了?求助。

能把代码发来学习下不?
244326867@qq.com ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号