D
DrewM
I have an xml document fragment that I'm trying to process:
<field id="summary" type="textarea" label="Summary" />
<field id="content" type="wysiwyg" label="Content" />
<field id="status" type="hidden" />
(this is part of a bigger document loaded into XML DOM)
I'm looping through the <field> elements and extracting their attributes
into variables:
<%
for i = 0 to oFields.length-1
nId = oFields(i).attributes.getNamedItem("id").text
sType = oFields(i).attributes.getNamedItem("type").text
sLabel = oFields(i).attributes.getNamedItem("label").text
...
next
%>
The problem arises with the label attribute, because it is optional.
Trying to retrieve the text of a non-existent attribute throws an error
"Object required: 'oFields(...).attributes.getNamedItem(...)' ".
How can I test for this so as to gracefully avoid the error?
I've tried isNull() and isObject(), but these don't help. I'm beginning
to think that the only way to do it is to throw an error and trap it.
(Yuck).
Any ideas?
Thanks
Drew
<field id="summary" type="textarea" label="Summary" />
<field id="content" type="wysiwyg" label="Content" />
<field id="status" type="hidden" />
(this is part of a bigger document loaded into XML DOM)
I'm looping through the <field> elements and extracting their attributes
into variables:
<%
for i = 0 to oFields.length-1
nId = oFields(i).attributes.getNamedItem("id").text
sType = oFields(i).attributes.getNamedItem("type").text
sLabel = oFields(i).attributes.getNamedItem("label").text
...
next
%>
The problem arises with the label attribute, because it is optional.
Trying to retrieve the text of a non-existent attribute throws an error
"Object required: 'oFields(...).attributes.getNamedItem(...)' ".
How can I test for this so as to gracefully avoid the error?
I've tried isNull() and isObject(), but these don't help. I'm beginning
to think that the only way to do it is to throw an error and trap it.
(Yuck).
Any ideas?
Thanks
Drew