Parsing XML file with Minidom has problem with cr/lf

"Peterson, Wayne" <[email protected]> Sat, 8 May 2010 23:43:09 -0700
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
This is a multi-part message in MIME format.

--===============1806983504==
Content-Transfer-Encoding: 7bit
Content-Class: urn:content-classes:message
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01CAEF42.E3BA9AB4"

This is a multi-part message in MIME format.

------_=_NextPart_001_01CAEF42.E3BA9AB4
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I am parsing an XML file with Python 2.6.5 minidom in Windows and it is
mostly working but minidom seems to have problems dealing with Windows
cr/lf characters. It creates an extra textnode that needs to be ignored
instead of just returning the xml elements. I have tried different
methods of opening the file but it doesn't seem to make a difference. It
is happiest when reading a file in Unix format.

=20

Wayne Peterson | Consultant
Sierra Systems

(T): 403-264-0955 (C): 403-710-9248 (F): 403-233-2108

7th Floor, Canadian Centre

833 4th Avenue SW
Calgary, Alberta, T2P 3T5

Management Consulting | System Integration | Managed Services
website: www.SierraSystems.com



----Notice Regarding Confidentiality----
This email, including any and all attachments, (this "Email") is =
intended only for the party to whom it is addressed and may contain =
information that is confidential or privileged.  Sierra Systems Group =
Inc. and its affiliates accept no responsibility for any loss or damage =
suffered by any person resulting from any unauthorized use of or =
reliance upon this Email.  If you are not the intended recipient, you =
are hereby notified that any dissemination, copying or other use of this =
Email is prohibited.  Please notify us of the error in communication by =
return email and destroy all copies of this Email.  Thank you.

------_=_NextPart_001_01CAEF42.E3BA9AB4
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
  <o:idmap v:ext=3D"edit" data=3D"1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal>I am parsing an XML file with Python 2.6.5 minidom =
in
Windows and it is mostly working but minidom seems to have problems =
dealing
with Windows cr/lf characters. It creates an extra textnode that needs =
to be
ignored instead of just returning the xml elements. I have tried =
different methods
of opening the file but it doesn&#8217;t seem to make a difference. It =
is
happiest when reading a file in Unix format.<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;margin-bottom:7.5pt'><b><span
style=3D'font-size:9.0pt;font-family:"Verdana","sans-serif";color:black'>=
Wayne&nbsp;Peterson
</span></b><b><span =
style=3D'font-size:9.0pt;font-family:"Verdana","sans-serif";
color:#E8AE10'>|</span></b><b><span =
style=3D'font-size:9.0pt;font-family:"Verdana","sans-serif";
color:black'> Consultant<br>
Sierra Systems<br>
</span></b><b><span =
style=3D'font-size:9.0pt;font-family:"Arial","sans-serif";
color:black'><br>
</span></b><b><span =
style=3D'font-size:7.5pt;font-family:"Verdana","sans-serif";
color:#E8AE10'>(T):</span></b><span =
style=3D'font-size:7.5pt;font-family:"Verdana","sans-serif";
color:black'> 403-264-0955 </span><b><span =
style=3D'font-size:7.5pt;font-family:
"Verdana","sans-serif";color:#E8AE10'>(C):</span></b><span =
style=3D'font-size:
7.5pt;font-family:"Verdana","sans-serif";color:black'> 403-710-9248 =
</span><b><span
style=3D'font-size:7.5pt;font-family:"Verdana","sans-serif";color:#E8AE10=
'>(F):</span></b><span
style=3D'font-size:7.5pt;font-family:"Verdana","sans-serif";color:black'>=

403-233-2108</span><span =
style=3D'font-size:12.0pt;font-family:"Verdana","sans-serif";
color:black'><o:p></o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:7.5pt;font-family:"Verdana","sans-serif";
color:black'>7th Floor, Canadian Centre<o:p></o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:7.5pt;font-family:"Verdana","sans-serif";
color:black'>833&nbsp;4th Avenue SW<br>
Calgary,&nbsp;Alberta, T2P 3T5<o:p></o:p></span></p>

<p class=3DMsoNormal><b><span =
style=3D'font-size:7.0pt;font-family:"Verdana","sans-serif";
color:black'>Management Consulting </span></b><b><span =
style=3D'font-size:7.0pt;
font-family:"Verdana","sans-serif";color:#E8AE10'>|</span></b><b><span
style=3D'font-size:7.0pt;font-family:"Verdana","sans-serif";color:black'>=
 System
Integration </span></b><b><span =
style=3D'font-size:7.0pt;font-family:"Verdana","sans-serif";
color:#E8AE10'>|</span></b><b><span =
style=3D'font-size:7.0pt;font-family:"Verdana","sans-serif";
color:black'> Managed Services<br>
</span></b><b><span =
style=3D'font-size:7.5pt;font-family:"Verdana","sans-serif";
color:black'>website: www.SierraSystems.com</span></b><o:p></o:p></p>

</div>

<p></p><p>----Notice Regarding Confidentiality----<br>This email, =
including any and all attachments, (this "Email") is intended only for =
the party to whom it is addressed and may contain information that is =
confidential or privileged.  Sierra Systems Group Inc. and its =
affiliates accept no responsibility for any loss or damage suffered by =
any person resulting from any unauthorized use of or reliance upon this =
Email.  If you are not the intended recipient, you are hereby notified =
that any dissemination, copying or other use of this Email is =
prohibited.  Please notify us of the error in communication by return =
email and destroy all copies of this Email.  Thank you.</body>

</html>

------_=_NextPart_001_01CAEF42.E3BA9AB4--

--===============1806983504==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig

--===============1806983504==--