0

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?

Jasonca1
  • 4,848
  • 6
  • 25
  • 42
  • Seems like a duplicate of https://stackoverflow.com/questions/51655130/changing-element-namespace-in-lxml – Daniel Haley Apr 07 '22 at 04:27
  • Does this answer your question? [changing element namespace in lxml](https://stackoverflow.com/questions/51655130/changing-element-namespace-in-lxml) – Valentino Apr 16 '22 at 21:28

0 Answers0