git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4ebcc1b
)
xpath() returns sfa.util.xml.XmlNode instances. Added iterchildren() method
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Thu, 10 Nov 2011 02:29:03 +0000
(21:29 -0500)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Thu, 10 Nov 2011 02:29:03 +0000
(21:29 -0500)
sfa/util/xml.py
patch
|
blob
|
history
diff --git
a/sfa/util/xml.py
b/sfa/util/xml.py
index
b2aea13
..
047c997
100755
(executable)
--- a/
sfa/util/xml.py
+++ b/
sfa/util/xml.py
@@
-46,7
+46,8
@@
class XmlNode:
def xpath(self, xpath, namespaces=None):
if not namespaces:
namespaces = self.namespaces
def xpath(self, xpath, namespaces=None):
if not namespaces:
namespaces = self.namespaces
- return self.node.xpath(xpath, namespaces=namespaces)
+ elems = self.node.xpath(xpath, namespaces=namespaces)
+ return [XmlNode(elem, namespaces) for elem in elems]
def add_element(name, *args, **kwds):
element = etree.SubElement(name, args, kwds)
def add_element(name, *args, **kwds):
element = etree.SubElement(name, args, kwds)
@@
-73,7
+74,10
@@
class XmlNode:
def unset(self, key):
del self.node.attrib[key]
def unset(self, key):
del self.node.attrib[key]
-
+
+ def iterchildren(self):
+ return self.node.iterchildren()
+
def toxml(self):
return etree.tostring(self.node, encoding='UTF-8', pretty_print=True)
def toxml(self):
return etree.tostring(self.node, encoding='UTF-8', pretty_print=True)