|
-
Quick way to check if an element exists?
I'm reading through all my xml elements. The structure is consistent between
all the children so it is easy to just go read in anything. In some cases
I add an additional element. If the element exists, I want to do something
different. The code looks like this:
Set node = item.selectSingleNode("description")
Then I use node.Text in some other functions. However, I do not see an easy
way to see setting the node has failed. Basically I can think of 3 options:
1) Make the structure consistent in all children, then check if the text
is "" or contains significant data.
2) Add error handling to blast through any problems and call different functions
if an error occurs, which indicates no element. I don't like this option
at all - kind of a major hack that leads to sloppy coding.
3) Create a function that goes through all children checking for a particular
element. I guess this would be the best option, but is this built into the
msxml parser? It seems like I shouldn't have to write this myself, that it
should be part of the parser and maybe I just don't see it.
Any thoughts?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks