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 8719967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:55:23+00:00 2026-06-13T06:55:23+00:00

I am trying to convert my script (https://github.com/fletchermoore/n2c2) to use the default package xml.etree

  • 0

I am trying to convert my script (https://github.com/fletchermoore/n2c2) to use the default package xml.etree instead of lxml. This was an oversight on my part, but now I am realizing it would be impossible to get my target audience to set up lxml on their macs.

I think that most of the code should just work by switching out the import, but when I tried it I found out that xml.etree handles namespaces differently (which I do not understand). Specifically, what would be the easiest way to convert the setTagNames function here. xml is created from the .fromstring() method.

def setTagNames(self, xml):
    officens = xml.nsmap['office']
    textns = xml.nsmap['text']
    drawns = xml.nsmap['draw']
    xlinkns = xml.nsmap['xlink']
    stylens = xml.nsmap['style']
    fons = xml.nsmap['fo']

    names = {}
    names['body'] = '{%s}body' % officens
    names['text'] = '{%s}text' % officens
    names['auto-styles'] = '{%s}automatic-styles' % officens
    names['list'] = '{%s}list' % textns
    names['list-item'] = '{%s}list-item' % textns
    names['p'] = '{%s}p' % textns
    names['line-break'] = '{%s}line-break' % textns
    names['tab'] = '{%s}tab' % textns
    names['span'] = '{%s}span' % textns
    names['frame'] = '{%s}frame' % drawns
    names['image'] = '{%s}image' % drawns

    names['href'] = '{%s}href' % xlinkns
    names['name'] = '{%s}name' % stylens
    names['style-name'] = '{%s}style-name' % textns
    names['font-weight'] = '{%s}font-weight' % fons
    names['text-underline-style'] = '{%s}text-underline-style' % stylens
    names['font-style'] = '{%s}font-style' % fons
    names['font-size'] = '{%s}font-size' % fons
    names['background-color'] = '{%s}background-color' % fons
    names['color'] = '{%s}color' % fons

    names['style'] = '{%s}style' % stylens
    names['text-properties'] = '{%s}text-properties' % stylens
    self.names = names
    self.builder.names = names
  • 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-13T06:55:24+00:00Added an answer on June 13, 2026 at 6:55 am

    I found the answer in another post: Accessing XMLNS attribute with Python Elementree?

    I used the function written by deancutlet to create the nsmap. Everything else in my code seems to work without modification.

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

Sidebar

Related Questions

Trying to use gem delayed_job from collectiveidea(https://github.com/collectiveidea/delayed_job) in my project, but it throws exception:
I'm trying to migrate from a Nexus maven repo to using https://github.com/jcaddel/maven-s3-wagon . Getting
I'm trying to convert the following unix shell script to windows: for strWorkerDirectory in
We are trying to convert a bash shell script into a Windows batch script.
I'm trying to convert a server side Ajax response script into a Django HttpResponse,
Hey gang, I'm trying to convert a legacy php script over to python and
I am trying to create a little script to convert video on windows using
I'm trying to create a shell script that shall convert certain Files according to
I am trying to use the jQuery CSV plugin, as documented here: http://code.google.com/p/js-tables/wiki/CSV According
I'm trying to convert a C# script that i had found on another site:

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.