473,383 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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
SelectSingleNode() to
process. I tried with
if(XmlNode.SelectSingleNode("ABC")!=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 55747


hb wrote:

I need to check if a node exists in a XmlDocument object before to use
SelectSingleNode() to
process. I tried with
if(XmlNode.SelectSingleNode("ABC")!=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.SelectSingleNode("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*******@yahoo.de> wrote in message
news:OS**************@TK2MSFTNGP10.phx.gbl...


hb wrote:

I need to check if a node exists in a XmlDocument object before to use
SelectSingleNode() to
process. I tried with
if(XmlNode.SelectSingleNode("ABC")!=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.SelectSingleNode("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
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...
1
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
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...
9
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 =...
1
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...
1
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...
4
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...
1
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 ...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.