Author Alexander.Tobias.Heinrich
Recipients Alexander.Tobias.Heinrich
Date 2013-06-10.13:59:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
First of all, I am not sure, if this is a bug in python itself - it could as well be a bug in the py-dom-xpath module ( or not a bug at all (but I find the latter to be highly unlikely).

Consider an XML document such as:
<?xml version="1.0" encoding="utf-8"?>
<Zoo xmlns=''>

If one creates a new Chimp-element using the xml.dom.createElement() function and then appends it to the Compound element, then the xpath module will not find the element unless the whole document is saved and then re-parsed.

Creating the element with xml.dom.createElementNS() and thus explicitly specifying its namespace works around the problem.

I consider this to be a bug, because in both cases, xml.dom will create the same valid XML, so I believe xpath should produce the same results in both cases, too. My believe, that the bug is in xml.dom is just a feeling and I could be wrong. I imagine, that xml.dom.createElement() forgets about adding the new element to its inherited namespace and adds it to the null namespace instead. In consequence xpath doesn't find the new element.

I originally posted a more verbose explanation of this issue to StackOverflow (see
), because I was unsure about whether this is a bug or not - and if it was, then in which module. Because I did not receive any feedback on that post, I have now decided to file it here as a bug report.

I attached a sample script that demonstrates the problem if (xpath dependency is installed). I tested it under Windows with Python 2.7.5 and 2.7.4.
Date User Action Args
2013-06-10 13:59:13Alexander.Tobias.Heinrichsetrecipients: + Alexander.Tobias.Heinrich
2013-06-10 13:59:13Alexander.Tobias.Heinrichsetmessageid: <>
2013-06-10 13:59:13Alexander.Tobias.Heinrichlinkissue18182 messages
2013-06-10 13:59:12Alexander.Tobias.Heinrichcreate