Click here to Skip to main content
15,906,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am trying to retrieve the name attributes of each user node in python on the XML file below. For that, I looked for which library I could use and I came across ElementTree.
But testing some examples from the documentation I found below, it doesn't work on the XML file below.

<?xml version="1.0" encoding="UTF-8"?>
<book xmlns:test="" xmlns:test2="" xmlns:xsi="">
    <user data-id="101">
    <user data-id="102">
    <user data-id="103">
    <user data-id="104">
    <user data-id="105">
    <user data-id="106">

What I have tried:

I did some tests in python and I think it's the book tag that makes it not work.
Could you show me the python code that allows to list all names of each user node?

Do you also have links to documentation on XML traversal in python and other libraries other than ElementTree?

Updated 1-Jan-23 13:03pm

1 solution

I'm not familiar with python, so I did a quick Google Search to see what information is out there: xml parsing in python - Google Search[^].

There is a lot out there to help you. This one caught my eye: XML parsing — The Hitchhiker's Guide to Python[^].

There are lots of other examples found using the search above.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900