Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:20:28+00:00 2026-06-12T05:20:28+00:00

I have an XML document which I am reading and appending to using ElementTree.

  • 0

I have an XML document which I am reading and appending to using ElementTree.
This has multiple namespaces declared. From what I can tell, ElementTree will only allow a single global namespace to be declared:

ET.register_namespace(prefix, uri)

I would like to write multiple namespaces out in the resulting file. If I try to manually append them using
root.set(prefix, uri)
Then they are put in the wrong order, and I get cElementTree.ParseError: unbound prefix: line 2, column 0

Edit: it turns out that I had a typo in the option I was setting. I corrected this, and it re-parses fine. So it looks like this is a viable solution.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:20:30+00:00Added an answer on June 12, 2026 at 5:20 am

    If you are not restricted to just using the standard library, I suggest you install and use the lxml package which provides the ElementTree API, and it has a number of advantages, including easily allowing you to have multiple namespaces in the same document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML document which looks something like this: <meadinkent> <record> <comp_div>MENSWEAR</comp_div> <sty_ret_type>ACCESSORIES</sty_ret_type>
I have got an XML document which looks something like this. <Root> <Info>....</Info> <Info>....</Info>
I am using MSXML3 and have loaded an xml document which is a HTML
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and
I have a single xml document (data.xml), which I display as HTML using an
I have XML tag that has the content which is HTML document. <xml-tag> <!--
I'm an XML newbie and I have an XML document (which I can't edit
I have an XML document which reads like this: <xml> <web:Web> <web:Total>4000</web:Total> <web:Offset>0</web:Offset> </web:Web>
I have an XML document from which I want to remove white spaces and
I've got a socket from which I'm reading XML data. However, this socket will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.