Quick way to check if an element exists?

webmasterbeta

New Member
I'm reading through all my xml elements. The structure is consistent betweenall the children so it is easy to just go read in anything. In some casesI add an additional element. If the element exists, I want to do somethingdifferent. 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 easyway 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 textis "" or contains significant data.2) Add error handling to blast through any problems and call different functionsif an error occurs, which indicates no element. I don't like this optionat all - kind of a major hack that leads to sloppy coding.3) Create a function that goes through all children checking for a particularelement. I guess this would be the best option, but is this built into themsxml parser? It seems like I shouldn't have to write this myself, that itshould be part of the parser and maybe I just don't see it.Any thoughts?
 
Back
Top