diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2002-03-07 00:05:35 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2002-03-07 00:05:35 +0000 |
commit | f742d3417905e5a0f4785f9684c3a7427e139ca7 (patch) | |
tree | 524469b1b576ec335c472ebf6a9933a9535b9cf5 /python/libxml.py | |
parent | 4e0e29746889d4a70728e6406eed2f546287bdd6 (diff) | |
download | libxml2-f742d3417905e5a0f4785f9684c3a7427e139ca7.tar.gz |
fixed xmlReconciliateNs(), added a Python test/example for inter-document
* tree.c python/tests/Makefile.am python/tests/cutnpaste.py:
fixed xmlReconciliateNs(), added a Python test/example for
inter-document cut'n paste
* python/libxml.py: fixed node.doc on document nodes and added
xpathEval() onto node objects
Daniel
Diffstat (limited to 'python/libxml.py')
-rw-r--r-- | python/libxml.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/python/libxml.py b/python/libxml.py index 8d994662..3c15102c 100644 --- a/python/libxml.py +++ b/python/libxml.py @@ -181,8 +181,11 @@ class xmlCore: elif attr == "doc": ret = libxml2mod.doc(self._o) if ret == None: - return None - return xmlDoc(_doc=ret) + if self.type == "document_xml" or self.type == "document_html": + return xmlDoc(_obj=self._o) + else: + return None + return xmlDoc(_obj=ret) raise AttributeError,attr # @@ -235,7 +238,7 @@ class xmlCore: ret = libxml2mod.doc(self._o) if ret == None: return None - return xmlDoc(_doc=ret) + return xmlDoc(_obj=ret) def free(self): libxml2mod.freeDoc(self._o) @@ -250,6 +253,20 @@ class xmlCore: def saveTo(self, file, encoding = None, format = 0): return libxml2mod.saveNodeTo(self._o, file, encoding, format) + # + # Selecting nodes using XPath, a bit slow because the context + # is allocated/freed every time but convenient. + # + def xpathEval(self, expr): + doc = self.doc + if doc == None: + return None + ctxt = doc.xpathNewContext() + ctxt.setContextNode(self) + res = ctxt.xpathEval(expr) + ctxt.xpathFreeContext() + return res + # # converters to present a nicer view of the XPath returns # |