I am trying to create an xml tree from a JSON object using lxml.etree. Some of the tagnames contin a colon in them something like :-
'settings:current' I tried using
'{settings}current' as the tag name but I get this :-
ns0:current xmlns:ns0="settings"
Yes, first read and understand XML namespaces. Then use that to generate XML-tree with namespaces:u
And you can combine that with default namespaces
Note, that you have to have an element with
nsmap=MY_NAMESPACES
in your XML-tree hierarchy. Then all descendand nodes can use that declaration. In your case, you have no that bit, so lxml generates namespaces names likens0
Also, when you create a new node use namespace URI for tag name, not namespace name:
{http://example.com/url-for-settings-namespace}current