473,398 Members | 2,404 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,398 software developers and data experts.

HOW TO CHECK WHETHER A NODE EXIST?

Siu
Hi,
in my ASP.NET (C#) application I would like to check in advance if a node
exist: my code is as follow:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(XML_FILENAME);
XmlNode nodeApplication = xmlDoc.SelectSingleNode(xmlPath);

Before launching the instruction xmlDoc.SelectSingoleNode(xmlPath), how
would like to check if my xmlPath exists in the Xml document... it is a soft
of Exception Handling I suppose, but I need help, please.

Thank you in advance.
Nov 12 '05 #1
1 21721


Siu wrote:

in my ASP.NET (C#) application I would like to check in advance if a node
exist: my code is as follow:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(XML_FILENAME);
XmlNode nodeApplication = xmlDoc.SelectSingleNode(xmlPath);

Before launching the instruction xmlDoc.SelectSingoleNode(xmlPath), how
would like to check if my xmlPath exists in the Xml document...


SelectSingleNode returns null if no node is found so you can test
if (nodeApplication != null)
to check whether the node exists. Of course that check is done after
SelectSingleNode is executed but I see no way to do such a check without
or before using the method.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2

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

Similar topics

1
by: praba kar | last post by:
Dear All In Php we can find in_array() function which function is mainly useful to check whether a specific value is exist in the array or not. But In python In cannot find any function like...
8
by: J Peterman | last post by:
Im having a nightmare trying to understand these nodes and linked lists. I've posted my code for my node.h, node.cpp, linkedlist.h and linkedlist.cpp files in separates replies. Can someone...
2
by: adam | last post by:
hello What query shoul I send to SQL serwer ( in transact SQL language ) to check does some database exist on serwer ? It similar to problem "does some table exist in database" - resolve to it...
2
by: Bob | last post by:
I have sitemap like XML, of which every element has an attribute "url", e.g. <record menu_id="240" name="Countries and States" url="Countries.aspx"> <record2 page_id="54" url="CountriesEdit.aspx"...
7
by: andylcx | last post by:
Hi all: The c++ language can check whether the file exist or not. I am wondering how c language does this job? Thanks a lot! Andy
11
by: ItsMe | last post by:
Hi, I've 50 MDI Forms in my project, so trying to create MDI Child Form from this procedure. But the problem is, unable to declare as "NewFormName". It gives me an error. Is there any other...
1
by: Philip Wagenaar | last post by:
I have an XML file that has a date element. I want to change this date to unix notation. This works, but if the XML does not have the element I cannot assign the DateField the value. How can I...
1
by: John Wilhelm | last post by:
I'm having a problem in by VB.net 2005 application. When i try to get a node from my app.config file the node come back with "nothing". The xmldocment loads OK, but I can't retrive a node. The...
3
by: SM | last post by:
I think that simpleXML is the best thing i've seen in PHP5. It's so simple (d'ho!) and easy to use when it comes to reading a simple XML file. The only thing i'm not sure how to achieve is...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.