471,594 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

HowTo: check for existence of xml attributes to prevent exception event from firing

I would like to check for the existence of an attribute in order to prevent
an exception from firing.

Could someone provide an example?

tia
Mike
Dec 5 '06 #1
3 1927
Hi Mike,

You can try selecting a single node and specify the attribute in an XPath
query. If the attribute is not there, the method will return null.

"/Employees//@ID" will select nodes under the Employees node containing
the ID attribute

For more on XPath queries, read
http://www.developer.com/net/net/article.php/3383961
On Tue, 05 Dec 2006 14:12:55 +0100, Mike-deerenews <ms******@agris.com>
wrote:
I would like to check for the existence of an attribute in order to
prevent
an exception from firing.

Could someone provide an example?

tia
Mike



--
Happy Coding!
Morten Wennevik [C# MVP]
Dec 5 '06 #2
"Morten Wennevik" <Mo************@hotmail.comschrieb im Newsbeitrag
news:op***************@tr024.bouvet.no...
<snip>
"/Employees//@ID" will select nodes under the Employees node containing
the ID attribute
Wouldn't that select the ID attributes of those nodes?
Dec 6 '06 #3
Well, yeah, but if you use this XPath in SelectNodes the return value
would the nodes those attributes belong to.
On Wed, 06 Dec 2006 14:22:28 +0100, Christof Nordiek <cn@nospam.dewrote:
"Morten Wennevik" <Mo************@hotmail.comschrieb im Newsbeitrag
news:op***************@tr024.bouvet.no...
<snip>
>"/Employees//@ID" will select nodes under the Employees node containing
the ID attribute

Wouldn't that select the ID attributes of those nodes?



--
Happy Coding!
Morten Wennevik [C# MVP]
Dec 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Richard L Rosenheim | last post: by
9 posts views Thread by Daniel Walzenbach | last post: by
8 posts views Thread by Topper | last post: by
25 posts views Thread by pamelafluente | last post: by
4 posts views Thread by davearkley | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.