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

  • Thread starter Thread starter Mike-deerenews
  • Start date Start date
M

Mike-deerenews

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
 
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
 
"/Employees//@ID" will select nodes under the Employees node containing
the ID attribute

Wouldn't that select the ID attributes of those nodes?
 
Well, yeah, but if you use this XPath in SelectNodes the return value
would the nodes those attributes belong to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top