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

  • Home
  • SEARCH
  • 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 8735161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:59:20+00:00 2026-06-13T09:59:20+00:00

So I am working on a browser based program, written in Python, that parses

  • 0

So I am working on a browser based program, written in Python, that parses XML data from multiple files in a directory, then returns the values of certain XML tags on the page. I have successfully been able to return the values from one of the XML files, but am hoping to collect data from every file within the directory and return the values in spreadsheet format. How do I parse the data from every XML file? Also, the XML files are not static, there will be new files coming and going. Thanks! Below is my code:

from xml.dom.minidom import parseString

import os
path = 'C:\Vestigo\XML'
listing = os.listdir(path)
for infile in listing:
    print infile

file = open(os.path.join(path,infile),'r')

data = file.read()
file.close()

dom = parseString(data)

xmlTag0 = dom.getElementsByTagName('Extrinsic')[0].toxml()
xmlData0 = xmlTag0.replace('<Extrinsic>','').replace('</Extrinsic>','')
xmlTag1 = dom.getElementsByTagName('DeliverTo')[0].toxml()
xmlData1 = xmlTag1.replace('<DeliverTo>','').replace('</DeliverTo>','')
xmlTag2 = dom.getElementsByTagName('Street1')[0].toxml()
xmlData2 = xmlTag2.replace('<Street1>','').replace('</Street1>','')
xmlTag3 = dom.getElementsByTagName('City')[0].toxml()
xmlData3 = xmlTag3.replace('<City>','').replace('</City>','')
xmlTag4 = dom.getElementsByTagName('State')[0].toxml()
xmlData4 = xmlTag4.replace('<State>','').replace('</State>','')
xmlTag5 = dom.getElementsByTagName('PostalCode')[0].toxml()
xmlData5 = xmlTag5.replace('<PostalCode>','').replace('</PostalCode>','')


import cherrypy
class Root(object):
    def index(self):
        return ('Order Number:', ' ', xmlData0, '<br>Name: ', xmlData1, '<br>Street   Address: ', xmlData2, '<br>City/State/Zip: ', xmlData3, ', ', xmlData4, ' ', xmlData5, ' ', """<br><br><a href="/exit">Quit</a>""")
    index.exposed = True

    def exit(self):
        raise SystemExit(0)
    exit.exposed = True

def start():
    import webbrowser
    cherrypy.tree.mount(Root(), '/')
    cherrypy.engine.start_with_callback(
        webbrowser.open,
        ('http://localhost:8080/',),
        )
    cherrypy.engine.block()

if __name__=='__main__':
    start()

EDIT: Updated with my solution below.

  • 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-13T09:59:21+00:00Added an answer on June 13, 2026 at 9:59 am

    In order to pull data from every file in the directory I used this code below:

    from xml.dom.minidom import parse, parseString
    import os, glob, re
    import cherrypy
    class Root(object):
        def index(self):
            path = 'C:\Vestigo\XML'
    
            TOTALXML = len(glob.glob(os.path.join(path, '*.xml')))
            print TOTALXML
            i = 0
    
            for XMLFile in glob.glob(os.path.join(path, '*.xml')):
                xmldoc = parse(XMLFile)
                order_number = xmldoc.getElementsByTagName('Extrinsic')[0].firstChild.data
                order_name = xmldoc.getElementsByTagName('DeliverTo')[0].firstChild.data
                street1 = xmldoc.getElementsByTagName('Street1')[0].firstChild.data
                state = xmldoc.getElementsByTagName('State')[0].firstChild.data
                zip_code = xmldoc.getElementsByTagName('PostalCode')[0].firstChild.data
                OUTPUTi = order_number+' '+order_name+' '+street1+' '+state+' '+zip_code
                i += 1
                print OUTPUTi
            return (OUTPUTi, """<br><br><a href="/exit">Quit</a>""")
        index.exposed = True
    
        def exit(self):
            raise SystemExit(0)
        exit.exposed = True
    
    def start():
        import webbrowser
        cherrypy.tree.mount(Root(), '/')
        cherrypy.engine.start_with_callback(
            webbrowser.open,
            ('http://localhost:8080/',),
            )
        cherrypy.engine.block()
    
    if __name__=='__main__':
        start()
    

    Thanks for your help everyone, and for the tip on answering my own question Sheena!

    • 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 Browser-based media player which is written almost entirely in
I have this tabs that are working perfect in any browser apart from IE
Background I am working on a browser-based UI that needs to fill the entire
I am working on a browser-based application that is essentially a Digital Audio Workstation.
I'm working on a browser-based application that needs to be able to get users'
I am working on a geolocation project that is browser-based and geared specifically towards
I'm working on a server in a distributed application that has browser clients and
I'm working on a browser-based RPG for one of my websites, and right now
Say I've been tasked to architect a product that will have a browser-based front
I'm working on a browser based applet game, and I intend to store 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.