pythonqtwebkit:nextSibing不';t返回null或None
下面是我用来获取给定节点所有子节点列表的代码片段。但是nextSibling()从不返回null,因此while循环将永远执行。请帮忙pythonqtwebkit:nextSibing不';t返回null或None,python,qt,pyqt,qtwebkit,Python,Qt,Pyqt,Qtwebkit,下面是我用来获取给定节点所有子节点列表的代码片段。但是nextSibling()从不返回null,因此while循环将永远执行。请帮忙 children = [ ] children.append(documentElement.firstChild()) curr_node = children[0] while curr_node.nextSibling(): print curr_node, len(children) children.append(curr_
children = [ ]
children.append(documentElement.firstChild())
curr_node = children[0]
while curr_node.nextSibling():
print curr_node, len(children)
children.append(curr_node.nextSibling())
curr_node = curr_node.nextSibling()
据我所知,nextSibling将始终返回QWebElement,但是您可以使用isNull()检查该元素是否为null元素 你可以登记 http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebelement.html#nextSibling
while not curr_node.nextSibling().isNull():
print curr_node, len(children)
children.append(curr_node.nextSibling())
curr_node = curr_node.nextSibling()