Skip to content
Snippets Groups Projects
Commit 0ddc150f authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

ENH: implemented child generation using xpath

parent 602132e7
Branches
No related tags found
2 merge requests!181Release 0.9.0,!174XML Converter
This commit is part of merge request !174. Comments created here will be created in the context of that merge request.
......@@ -75,7 +75,15 @@ class XMLTagConverter(Converter):
if not isinstance(element, XMLTagElement):
raise TypeError("Element must be an instance of XMLTagElement.")
nsmap = self.definition["nsmap"]
# Get the namespace map from the element:
nsmap = element.tag.nsmap
# The default name of the default namespace is "default".
# You can overwrite it using the attribute "default_namespace" in the converter definition:
default_namespace = self.definition.get("default_namespace", "default")
if None in nsmap:
nsmap[default_namespace] = nsmap[None]
del nsmap[None]
xpath = self.definition.get("xpath", "child::*")
children = element.tag.xpath(xpath, namespaces=nsmap)
el_lst = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment