Parse bad xml file

David Jobes at
Fri Oct 10 13:46:14 CEST 2014

I was given a badly or poor formatted xml file that i need to convert to csv file:

<?xml version="1.0"?>
<resultset xmlns:dyn="">
<table name="SIGNATURE">
	<column name="ID" type="String">	</column>
	<column name="NUM" type="Integer">	</column>
	<column name="SEVERITY_ID" type="Integer">	</column>
	<column name="NAME" type="String">	</column>
	<column name="CLASS" type="String">	</column>
	<column name="PRODUCT_CATEGORY_ID" type="Integer">	</column>
	<column name="PROTOCOL" type="String">	</column>
	<column name="TAXONOMY" type="String">	</column>
	<column name="CVE_ID" type="String">	</column>
	<column name="BUGTRAQ_ID" type="String">	</column>
	<column name="DESCRIPTION" type="String">	</column>
	<column name="MESSAGE" type="String">	</column>
	<column name="FILTERTYPE" type="String">	</column>
			<c>0027: IP Options: Record Route (RR)</c>

I have been able to load and read the file line by line, but once i get to the r line and try to process each c(column) that is where it blows up. I need to be able to split the lines and place each one or the r (row) on a single line for the csv.

i have a list set for each one of the headers based on the col name field, i just have been able to format properly. 

More information about the Python-list mailing list