I am parsing an XML file in ASP. It appears you can’t have an empty node or else I get this error:
Microsoft VBScript runtime error '800a01a8'
Object required: 'objHdl.childNodes(...).childNodes(...)'
/post/resources/courses/DOP/vtod/index.asp, line 96
Sometimes the node will be populated other times it wont and I need to check that.
Here is my code that is reading the XML and outputting html:
Response.Write("<table width=""800"" cellpadding=""5"" cellspacing=""20"" border=""0"">" & vbCRLF)
For i = 0 To (noOfHeadlines - 1)
needFooter = true
Set objHdl = objLst.item(i)
if i mod numCols = 0 then
Response.Write("<tr>")
end if
Response.Write("<td class=""courseTable"" valign=""top"" width=""33%"">" & vbCRLF &_
"<div id=""thumbs"" class=""thumb""><a tipcontent=""" & objHdl.childNodes(2).childNodes(0).text & """ href=""" & objHdl.childNodes(7).childNodes(0).text & """>" & vbCRLF &_
"<img id=""thumb_" & headlineNum & """ border=""0"" src=""" & objHdl.childNodes(5).childNodes(0).text & """ onmouseover=""hoveron(" & headlineNum & ");"" onmouseout=""hoveroff(" & headlineNum & ");""/>" & vbCRLF &_
"<div id=""playbtn_" & headlineNum & """ style=""position:relative; top: -80px; left: 0px; z-index:5; display:none;"">" & vbCRLF &_
"<img border=""0"" src=""images/btn-play-big.png"" onmouseover=""hoveron(" & headlineNum & ");"" onmouseout=""hoveroff(" & headlineNum & ");""/>" & vbCRLF &_
"</div></a></div>" & vbCRLF &_
"<span class=""chantitle""><a href=""" & objHdl.childNodes(7).childNodes(0).text & """>" & objHdl.childNodes(1).childNodes(0).text & "</a></span><br />" & vbCRLF &_
"<span class=""chanlength"">Length: " & objHdl.childNodes(6).childNodes(0).text & "</span><br />" & vbCRLF &_
"<span class=""chanstatus"">" & objHdl.childNodes(3).childNodes(0).text & "</span></td>" & vbCRLF)
//^^^ this line broken if empty^^^
headlineNum = headlineNum + 1
if i mod numCols = numCols - 1 then
Response.Write("</tr>")
needFooter = false
end if
Next
if needFooter then
Response.Write("<td colspan=""" & numCols - (i mod numCols) & """></td></tr>")
end if
Response.Write("</table>")
I’ve tried ‘if Not isNull(the node)’ and that didnt work. Anyone know how to do this?