473,769 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2041
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.comsch rieb im Newsbeitrag
news:op******** *******@tr024.b ouvet.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.dewr ote:
"Morten Wennevik" <Mo************ @hotmail.comsch rieb im Newsbeitrag
news:op******** *******@tr024.b ouvet.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
1563
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 solve this so it compare 2 > 10 as, is two bigger than ten, and not, is two bigger than one. Thanx in advance
5
19539
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" state="CA" /> What's the best why of determining if the attribute zipcode exists in this node? If I try accessing the attribute with code like: ZipCode = myNode.Attributes("zipcode").Value
2
3809
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 stirng if the XML does validate againsg the schema. What's the easiest way to do this? Kind Regards, Allan Ebdrup
9
2284
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) as a popup using either window.open or window.showModalDialog. Since I want to warn the users of my application when they try to close page1.aspx and have changed the values in the meantime I thought about using the “onbeforeunload” event of the...
8
4195
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 this without .config file only with some configuration
25
29762
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" name="ClickedElement" id="Messenger" /> </form> </body>
4
1823
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 a class which have zero, one or more custom attributes associated with each field. I'd like to get a list of the attributes present for a given field, and then iterate over them to find associated values. Where I've coded for the presence of...
2
2851
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 need some custom javascript validation on form submit but why does is kill the submit button event handler? Submit buttons don't use __doPostBack so what is being effected?
19
108019
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 sure that the user only submits a number to your .NET web application and also demonstrate how to add JavaScript to your ASPX pages. Upon popular demand, I have added a section that also covers how to use a validator control to check if a text box...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.