Xml Don';“我不明白”;“所需对象”;错误

Xml Don';“我不明白”;“所需对象”;错误,xml,asp-classic,parent-child,parent,Xml,Asp Classic,Parent Child,Parent,我有以下ASP经典功能: function get_children(n) dim local_array dim parent dim path if n.hasChildNodes() then for each child in n.childNodes local_array = array_merge(local_array, get_children(child)) next else set parent = n.parent

我有以下ASP经典功能:

function get_children(n)
  dim local_array
  dim parent
  dim path
  if n.hasChildNodes() then
    for each child in n.childNodes
      local_array = array_merge(local_array, get_children(child))
    next
  else
    set parent = n.parentNode
    while isobject(parent)
      path = parent.nodeName & "/" & path
      set parent = parent.parentNode
    wend
    path = path & "/" & get_attr(n, "file")
    set_attr n, "path", path
    local_array = Array(0)
    set local_array(0) = n
  end if
  get_children = local_array
end function
在一个XML节点(来自Microsoft.XMLDOM对象)上运行此操作,我会得到错误
所需的对象:'parent'

path = parent.nodeName & "/" & path

我不明白为什么。我正在检查
isobject
。有人能解释一下运行时在抱怨什么以及为什么吗?

我不是100%确定,但是如果
IsObject
,也许你应该用一些东西来代替它?我建议试试
IsEmpty()
IsNull()
或者
什么都不是。后者的用法如下:

If Not (myObject Is Nothing)

当不再有父节点时,您将返回空值,即
。但是,
Nothing
是“空对象”,因此它也是一个对象。
IsObject(Nothing)
的值为
True

检查
Nothing
,而不是检查变量是否包含对象:

while not (parent is Nothing)