MDN wants to learn about developers like you:

XUL Parser in Python/source

Source code for the XUL Parser in Python.

import sys, glob, xmllib
import os, re
el_list = {}
w = open('res.html', 'w')

# Unfortunately, I had to put this hack in here to suppress the printing out of the resolved namespace: 
# "xmlns=" window", etc.

def strip(snip):
	t = re.sub('http://.*?\s', '', snip)
	return t
class XULParser(xmllib.XMLParser):
	def unknown_starttag(self, t, a):
		name = strip(t)
		if name not in el_list: el_list[name] = {}
		for attr,val in a.items():
			el_list[name][strip(attr)] = strip(val)
	def syntax_error(self, message):

p = XULParser()

cmd = 'dir /s /b *.xul'
CHROME_DIR = 'C:\Program Files\Netscape\Netscape 6\chrome' 
files = os.popen(cmd).readlines()
for file in files:
	file = file.strip()
	print '** ' + file + ' **'
	data = open(file).read()

w.write('<html><h3>Periodic Table of XUL Elements</h3>')
w.write('<table><style>.head {font-weight: bold; background-color: lightgrey;}</style>')
elements = el_list.keys()
for item in elements:
	w.write('<tr><td class="head">' + item + '</td></tr>\n')
	for a in el_list[item]:
		w.write('<tr><td class="at">' + a + '</td>')

Document Tags and Contributors

 Contributors to this page: teoli, ethertank, newacct, Nickolay, Pd
 Last updated by: ethertank,