The above line works fine if a "description" element exists, but produces an error message if it does not. Can anyone describe code that could be used to check whether an element does or does not exist? Thanks
TravelSite, You have to remember, when using classic asp to parse xml, when you "set" a variable to hold a node, it then becomes an object.
So, when this happens, you can use the IsObject(Expression) function to test.
Example: If isObject(products(counter).selectSingleNode("description")) Then Response.Write products(counter).selectSingleNode("description").firstChild.nodeValue Else Response.Write("Does not exist.") End If
The IsObject function tests the variable to see if it is an object pointer. Nothing is the reserved value for an empty/null object pointer. So, if the node evaluates to Nothing, IsObject will still return True. Instead, you need to compare it to Nothing. It looks like a double negative when you do it:
Dim objTest Set objTest = products(counter).selectSingleNode("description").firstChild If Not (objTest Is Nothing) Then Response.Write objTest.nodeValue End If
oops - I didn't see the last part of your last post. Never mind.[/edit]