Retriving a tag value from multiple XML files in a directory using python
Question: I am currently learning python to automate a few things in my job. I need to
retrieve a tag value from multiple xml files in a directory. The directory has
many subfolders too.

I tried the following code, and understood what is missing. But I am not able
to fix this. Here is my code:

    
    
    from xml.dom.minidom import parse, parseString
    import os
    def jarv(dir):
    for r,d,f in os.walk(dir):
        for files in f:
            if files.endswith(".xml"):
                print files
                    dom=parse(files)
                name = dom.getElementsByTagName('rev')
                print name[0].firstChild.nodeValue
    jarv("/path)
    

I understand that while executing the `dom=parse(files)` line, it has got the
filename without the path. So it says no such files/directory.

I don't know how to fix this.


Answer: You have to use os.path.join() to build the correct path from the dirname and
the filename:

    
    
    dom=parse(os.path.join(r, files))
    

should do it

