1 year ago
#384867

Jasonca1
lxml override root element namespace
I have an xml document that resembles the following:
<?xml version='1.0' encoding='UTF-8'?>
<document xmlns='https://www.example.com' xmlns:asi='http://www.w3.org/1999/xhtml'>
<articleID>1234567890</articleID>
<article>
<title>Some random title</title>
</article>
</document>
Using lxml, I want to be able to override/replace the root element's namespace/nsmap so that it resembles the following:
<?xml version='1.0' encoding='UTF-8'?>
<document xmlns='https://www.somethingelse.com' xmlns:asi='http://www.w3.org/1999/xhtml'>
<articleID>1234567890</articleID>
<article>
<title>Some random title</title>
</article>
</document>
How could I accomplish that using lxml?
python
xml
namespaces
lxml
0 Answers
Your Answer