
July 1, 2008
1:20 a.m.
Hi, Eric Jahn wrote:
type="{http://domain2.info}someattribute
element = etree.Element(NS2 + "secondelement", nsmap=NSMAP, type = NS2 + "someattribute")
You are setting a namespace as attribute /value/ here, not as attribute /name/. lxml will not modify content unless you tell it to do so. If you want it to replace the namespace by a resolved prefix, use type = etree.QName(NS2 + "...") If it's just a mistake and you wanted to set the attribute /namespace/ instead, pass attrib = {NS2 + "someattribute" : "somevalue"} to the Element factory. There should also be a section on this in the tutorial IIRC. Stefan