473,554 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help: How to check if a node exists?

hb
Hi,

I need to check if a node exists in a XmlDocument object before to use
SelectSingleNod e() to
process. I tried with
if(XmlNode.Sele ctSingleNode("A BC")!=null)
But this only works when the node "ABC" exists. If the node doesn't exists,
I will get an error
saying object not found. Would you please give me some help?

Thank you

hb
Nov 12 '05 #1
2 55785


hb wrote:

I need to check if a node exists in a XmlDocument object before to use
SelectSingleNod e() to
process. I tried with
if(XmlNode.Sele ctSingleNode("A BC")!=null)
But this only works when the node "ABC" exists. If the node doesn't exists,
I will get an error
saying object not found. Would you please give me some help?


If you use
XmlNode node = xmlDocument.Sel ectSingleNode(" ABC");
if (node != null)
I don't see a problem.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #2
hb
It works. Thank you, Martin.
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:OS******** ******@TK2MSFTN GP10.phx.gbl...


hb wrote:

I need to check if a node exists in a XmlDocument object before to use
SelectSingleNod e() to
process. I tried with
if(XmlNode.Sele ctSingleNode("A BC")!=null)
But this only works when the node "ABC" exists. If the node doesn't exists, I will get an error
saying object not found. Would you please give me some help?


If you use
XmlNode node = xmlDocument.Sel ectSingleNode(" ABC");
if (node != null)
I don't see a problem.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4176
by: RDRaider | last post by:
I am having trouble with what will surely be a simple query for you experts. I have 2 tables with inventory data. IMITMIDX contains the master item info IMINVLOC contains location specific data such as quantity on hand at that location. These tables have 2 commons fields, ITEM_NO and LOC I need to search the IMINVLOC table for any...
1
2083
by: Gene Vangampelaere | last post by:
Hello, How can I check if a parameter (node) already exists in my xmldocument? If it does not exists I have to add it example: If ExistsNode("SID") Then 'add the node End If
10
4498
by: Raymond | last post by:
Hi All: To find a file exists using the file name, I have tow routings on UNIX system. 1. access(2) 2. lstat(2) This tow function also can do. When the return value is "-1" and errno is "ENOENT", The file doesn't exist.
9
4311
by: Dino Buljubasic | last post by:
If I want to delete a file I can call File.Delete(filePath) but what happens if I am trying to delete the file that is open??? In java you would do someting like int status = fileExists(filePath) // return 0, 1, or 2 2 means file exists and it si open but VB returns boolean value telling file exist or not
1
2814
by: James | last post by:
vb.net 2003 i wrote a windows service that does threading. My codes are a) the service thread will read a list of machine from a text file (machines.txt). b) it then logon using the below Dim returnValue As Boolean = LogonUser(m_ntid, m_domain, m_pwd, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, tokenHandle)
1
1721
by: shirantha | last post by:
Hi, I need to check for a particular window which I opened as a popup, already exists, before I try to open the same again. I achieved that with the following code. So this is fine. var myWin = null; function openPopup(aURL){ if (( myWin==null) || myWin.closed) { myWin = open(aURL,"myWin");
4
8766
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; If I have an XPathNavigator object and for a given xpath statement need to know if the node exists, how should I do this? I have found for some xpath functions it returns an empty string if the node does not exist but that is also the result for an empty node. -- thanks - dave david_at_windward_dot_net
1
2238
by: yousuf20022002 | last post by:
Hi Guys, I am struck with something in XML.Here it is what I am doing ... xml format is like <root> <user1> <details> <firstname>asdf </firstname> <lastname>mhmm </lastname>
2
9800
Manikgisl
by: Manikgisl | last post by:
HI. How to check File exists in Web Share C# try { WebRequest request = HttpWebRequest.Create("http://www.microsoft.com/NonExistantFile.aspx"); request.Method = "HEAD"; // Just get the document headers, not the data. request.Credentials = System.Net.CredentialCache.DefaultCredentials; // This may throw a WebException:
0
7578
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7780
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7530
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5414
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3539
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1111
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.