469,326 Members | 1,462 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

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 54849


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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by RDRaider | last post: by
1 post views Thread by Gene Vangampelaere | last post: by
10 posts views Thread by Raymond | last post: by
9 posts views Thread by Dino Buljubasic | last post: by
1 post views Thread by shirantha | last post: by
4 posts views Thread by =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.