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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:52:00+00:00 2026-05-27T00:52:00+00:00

I want to read simple excel xml file to dictionary. I have tried to

  • 0

I want to read simple excel xml file to dictionary. I have tried to use xlrd 7.1 but it returns format errors. Now i’m trying to use xml.etree.ElementTree and also without success. I can’t change structure of .xml file. Here my code:

<?xml version="1.0" encoding="UTF-8"?>
-<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="http://www.w3.org/TR/REC-html40">
  -<Styles>
    -<Style ss:Name="Normal" ss:ID="Default">
      <Alignment ss:Vertical="Bottom"/>
      <Borders/>
      <Font ss:FontName="Verdana"/>
      <Interior/>
      <NumberFormat/>
      <Protection/>
    </Style> -<Style ss:ID="s22">
      <NumberFormat ss:Format="General Date"/>
    </Style>
  </Styles> -<Worksheet ss:Name="Linkfeed">
    -<Table>
      -<Row>
        -<Cell>
          <Data ss:Type="String">ID</Data>
        </Cell> -<Cell>
          <Data ss:Type="String">URL</Data>
        </Cell>
      </Row> -<Row>
        -<Cell>
          <Data ss:Type="String">22222</Data>
        </Cell> -<Cell>
          <Data ss:Type="String">Hello there</Data>
        </Cell>
      </Row>
    </Table>
  </Worksheet>
</Workbook>

Reading:

import xml.etree.cElementTree as etree

def xml_to_list(fname):
        with open(fname) as xml_file:
                tree = etree.parse(xml_file)

                for items in tree.getiterator(tag="Table"):
                        for item in items: # Items is None!
                                print item.text

Update, now it works, but how to exclude junk?

def xml_to_list(fname):
        with open(fname) as xml_file:
                tree = etree.iterparse(xml_file)
                for item in tree:
                        print item[1].text
  • 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-05-27T00:52:00+00:00Added an answer on May 27, 2026 at 12:52 am

    Exclude “junk” with an if-statement:

    def xml_to_list(fname):
        with open(fname) as xml_file:
                tree = etree.iterparse(xml_file)
                for item in tree:
                     if item[1].text.strip() != '-':
                            print item[1].text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file. I want read that file. But In that if
I want to read a simple foxpro dbf file and convert it into xml
Question is simple, i have a object file and i want to read the
Hi I can't understand this error I want read this XML file: <?xml version=1.0
I want to read the pdf file from raw folder if devices have any
I have a perl script read Excel file and parse using a perl module
I have a simple Excel 2007 Macro that is reading a text file line
I guess this is a quite simple (read: very simple) question, but I have
I have a simple string that I want to read into a float without
i have a simple database tree with parentid and i want to read the

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.