Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78943

Parse bad xml file

Newsgroups comp.lang.python
Date 2014-10-10 04:46 -0700
Message-ID <9bb1f027-dc72-43c1-9301-e2105225f75a@googlegroups.com> (permalink)
Subject Parse bad xml file
From David Jobes <david.jobes.sony@gmail.com>

Show all headers | View raw


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="http://exslt.org/dynamic">
<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>
	<data>
		<r>
			<c>00000001-0001-0001-0001-000000000027</c>
			<c>27</c>
			<c>2</c>
			<c>0027: IP Options: Record Route (RR)</c>
			<c>Network_equip</c>
			<c>10</c>
			<c>ip</c>
			<c>100741885</c>
			<c>2001-0752,1999-1339,1999-0986</c>
			<c>870</c>
			<c></c>
			<c></c>
			<c></c>
		</r>


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. 

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Parse bad xml file David Jobes <david.jobes.sony@gmail.com> - 2014-10-10 04:46 -0700
  Re: Parse bad xml file Peter Otten <__peter__@web.de> - 2014-10-10 14:20 +0200
    Re: Parse bad xml file David Jobes <david.jobes.sony@gmail.com> - 2014-10-10 05:33 -0700
      Re: Parse bad xml file Rustom Mody <rustompmody@gmail.com> - 2014-10-12 01:37 -0700

csiph-web