I am discovering the awesomeness that is XML.
I use an application called Final Cut Pro for editing video. The app is able to export is projects as XML.
I am trying to develop a script to read that script and build a list of the files that are listed in the XML. The projects' imported files are enclosed in the 'pathurl' tag in the XML file.
It is nearly working but I just wanted to see what you guys think of the manner I have approached it.
Currently it spits out a list, but the information is enclosed in the xml element tag - it would be great to get a list without the tags.
example (current output):Is there an 'XML parsing call' (sorry i am making up programming lingo as I go) to do this, or is it a matter of using a python tool like strip/split ?
<pathurl>file://localhost/Volumes/HD1/FCP_Documents/Projects/Media/Petronas_mediamanaged_07AUG07/research.tif</pathurl>
example of what I'd like:
/Volumes/HD1/FCP_Documents/Projects/Media/Petronas_mediamanaged_07AUG07/research.tif
Thanks for any advice!
Adam
Expand|Select|Wrap|Line Numbers
- import sys
- import os
- from xml.dom import minidom
- xmldocumentpath = str(sys.argv[1])
- elementtofind = 'pathurl'
- xmldoc = minidom.parse(xmldocumentpath)
- pathlist = xmldoc.getElementsByTagName(elementtofind)
- pathlist
- # All Nodes listed
- # AllNode = xmldoc.firstChild
- itemamount = len (pathlist)
- print itemamount
- loop = 0
- while loop < itemamount:
- print pathlist[loop].toxml()
- loop = loop + 1