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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:53:57+00:00 2026-06-07T16:53:57+00:00

Brand new to XML parsing. What would be the best way in python to

  • 0

Brand new to XML parsing. What would be the best way in python to parse something like:

<Item name="item1">
    <data>item1data</data>
    <subItems>
        <Item name="item2">
            <data>item2data</data>
            <subItems>
                <Item name="item3">
                  . . .
                </Item>
            </subItems>
        </Item>
        <Item name="item4">
          . . .
        </Item>
    <subItems>
</Item>

I was looking at xml.sax parsing, but couldn’t figure out how to enable it to do multiple levels of parsing down the subItems trees. Could someone give me a recommendation of a parser/method to parse this? Thank you!

I will be creating lists of ‘Item’ objects with this, expected results would loopks something like this:

[Item(item1, item1data, 
    [Item(item2, item2data, 
        [Item(item3 ... ]) Item(item4 ... )])]`
  • 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-07T16:53:58+00:00Added an answer on June 7, 2026 at 4:53 pm

    One of the best ways in python to parse xml is to use the lxml package that can be located at:
    http://lxml.de/

    It includes backwards compatibility with the python built-in module ElementTree and provides xPath support.

    Here’s a tutorial to get you started:
    http://lxml.de/tutorial.html

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

Sidebar

Related Questions

I'm new to xml parsing, I am trying to parse the following xml file
Brand new to the Log4Net library and there is something I have not been
Brand new to Python (and programming in general), if this is simple and/or answered
I'm brand new at Python and I'm trying to write an extension to an
I am looking to start work on a brand-new project, something I've been thinking
I'm brand new to Atom feeds. I'd like to set-up a basic feed. What
I am brand new to actually using an API, getting the JSON data and
Brand new to Cocoa and I'm trying to figure out how to copy an
Brand new poster here on StackOverflow. I've been reading and learning here for some
I'm brand new to node.js, but I wanted to play around with some basic

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.