[Lxml-checkins] r32373 - in lxml/branch/lxml-1.1: . src/lxml
scoder at codespeak.net
scoder at codespeak.net
Fri Sep 15 19:10:16 CEST 2006
Author: scoder
Date: Fri Sep 15 19:10:15 2006
New Revision: 32373
Modified:
lxml/branch/lxml-1.1/CHANGES.txt
lxml/branch/lxml-1.1/src/lxml/objectify.pyx
Log:
countchildren() method on ObjectifiedElement
Modified: lxml/branch/lxml-1.1/CHANGES.txt
==============================================================================
--- lxml/branch/lxml-1.1/CHANGES.txt (original)
+++ lxml/branch/lxml-1.1/CHANGES.txt Fri Sep 15 19:10:15 2006
@@ -8,6 +8,8 @@
Features added
--------------
+* countchildren() method on objectify.ObjectifiedElement
+
* Support custom elements for tree nodes in lxml.objectify
Bugs fixed
Modified: lxml/branch/lxml-1.1/src/lxml/objectify.pyx
==============================================================================
--- lxml/branch/lxml-1.1/src/lxml/objectify.pyx (original)
+++ lxml/branch/lxml-1.1/src/lxml/objectify.pyx Fri Sep 15 19:10:15 2006
@@ -184,6 +184,21 @@
c_node = c_node.prev
return count
+ def countchildren(self):
+ """Return the number of children of this element, regardless of their
+ name.
+ """
+ # copied from etree
+ cdef Py_ssize_t c
+ cdef xmlNode* c_node
+ c = 0
+ c_node = self._c_node.children
+ while c_node is not NULL:
+ if _isElement(c_node):
+ c = c + 1
+ c_node = c_node.next
+ return c
+
def __getattr__(self, tag):
"""Return the (first) child with the given tag name. If no namespace
is provided, the child will be looked up in the same one as self.
More information about the lxml-checkins
mailing list