473,378 Members | 1,536 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,378 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 2024
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: KS | last post by:
I got 2 inputs in a form where I want check if start > end. Seems like it just compare the first number when I got this code in javascript "if(document.all.start > document.all.end)" How do i...
5
by: Richard L Rosenheim | last post by:
What's the proper technique for checking for the existence of an attribute within a node? Lets say I did a SelectSingleNode which returned this element: <AnAddress city="San Francisco"...
2
by: Allan Ebdrup | last post by:
Hi I have two strings in memory, a XML document and a Schema, I would like a function that takes these two as parameters and returns an errordescription if the XML does not validate and an empty...
9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
8
by: Topper | last post by:
Hello. I have simple web folders structure: -ROOT - BIN WebService.dll WebService.asmx I need to use my WebService.dll not in bin folder - for example, in ROOT. How do i this? How can i do...
25
by: pamelafluente | last post by:
Hi Guys, I have the following HTML code which is doing a GET to a page, say MyUrl.aspx : <body> <form name="form1" method="get" action="MyUrl.aspx" id="form1"> <input type="hidden"...
4
by: davearkley | last post by:
I've recently 'discover' the wonders of custom attributes and reflection. There's one aspect that has stumping me and I've been unable to find samples in the docs or on the web. I have fields in...
2
by: APA | last post by:
Why does adding code to the form submit function using the RegisterOnSubmitStatement method prevent the server side event handler for the submit button from firing? This is completely useless. I...
19
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.