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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:45:47+00:00 2026-06-18T22:45:47+00:00

I am kinda new to Python. I am working on a project that parses

  • 0

I am kinda new to Python. I am working on a project that parses an XML in Python and my Python code to do so is :

from xml.dom import minidom
from copy import copy

class Xmlparse:


    def __init__(self, xmlfile):
        self = minidom.parse(xmlfile)

    def findadress(self):
        itemlist =self.getElementsByTagName('addresses')
        return itemlist[0].attributes['firstname'].value


if __name__ == '__main__':
    with open("sample.xml") as f:

        parse = Xmlparse(f)
        print parse.findadress()

But when I run this code I get an output error:

AttributeError: Xmlparse instance has no attribute 'findadress'

And findadress function is spelled correctly in the main, but for some reason what so ever i am getting this error.

Any help is really appreciated.

And I also wanted to know, how can I validate the xml with an XSD schema in python?

  • 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-18T22:45:48+00:00Added an answer on June 18, 2026 at 10:45 pm

    “self = minidom.parse(xmlfile)” overwrites the Xmlparse object you just created. You want to assign the xml doc to a variable instead:

    from xml.dom import minidom
    from copy import copy
    
    class Xmlparse:
    
        def __init__(self, xmlfile):
            self.doc = minidom.parse(xmlfile)
    
        def findadress(self):
            itemlist =self.doc.getElementsByTagName('addresses')
            return itemlist[0].attributes['firstname'].value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a Python module that suppose to checkout some code from
I am working on a new Python package that depends upon many rather large
I'm kinda new to Flex. I have trying to send Hash from Ruby on
I am kinda new to this Regex thing. When analyzing some code I frequently
----Complete Rephrasing---- I was working on a new class where each instance was essentially
I was working on a program,that I need to support new additions. Hmmm. Let
I'm new at Python, and I'm pretty sure that the cause of this is
Im New To Pygame But Kinda OK On Python, Im Creating A Zombie Shooting
I am using threading.py and I have the following code: import threading class MyClass(threading.Thread):
I'm kinda' new to python, but I have already written many programs including some

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.