somebody to help me about parsedxml?

"amine soulaymani" <[email protected]> Fri, 8 Aug 2003 11:39:28 -0000
Newsgroups gmane.comp.web.zope.parsed-xml
Message-ID <[email protected]>
This is a multi-part message in MIME format.

--===============90053145367332244==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_000D_01C35DA1.B98ED7D0"

This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C35DA1.B98ED7D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

somebody to help me?
i'm working with parsedxml, and i have huge quantity of xml documents to =
parse under zope, but:
1 - they contains some non-ascii caracters (=E9,=E8,=E0)
2 -  I can"t modify the "site.py" file to change the default python =
encoding.
3- I can't modify parsedxml source.
I have to do all the ascii to unicode conversion in internal python =
script, not even in external methods.
example:=20
consider that xml, stored under zope as xmlfile:

<?xml version=3D"1.0" encoding=3D"iso-8859-1"?><control>
<utilisateur type=3D"facturation" qualite=3D"2">
<nom titre=3D"M">Bonn=E9</nom>
<prenom>Jean</prenom> <telmobile>0645237379</telmobile>
<email>[email protected]</email></utilisateur>
<adresse type=3D"facturation">
<rue1>14 rue d'avant=E9</rue1>=20
<cpostal>75015</cpostal>=20
<ville>PARIS</ville> </adresse>
<adresse type=3D"livraison">
<rue1>14 rue d'apr=E8s</rue1>=20
<cpostal>75015</cpostal>=20
<ville>PARIS</ville> </adresse>
<infocommande>
<montant devise=3D"EUR">88</montant>=20
<refid>Cmde-004</refid>=20
<siteid>112</siteid></infocommande></control>

there is an accentued character at line 3.
this python script raises exception:

for items in container.xmlfile.documentElement.childNodes:
   print items
return printed

Error Type: UnicodeError
Error Value: ASCII encoding error: ordinal not in range(128)

how to proceed to print that without modify the parsedxml source nor the =
site.py file?


------=_NextPart_000_000D_01C35DA1.B98ED7D0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>somebody to help me?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i'm working with parsedxml, and i have =
huge=20
quantity of xml documents to parse under zope, but:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>1 - they contains some non-ascii =
caracters=20
(=E9,=E8,=E0)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>2 -&nbsp;&nbsp;I can"t modify the =
"site.py" file to=20
change the default python encoding.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>3-&nbsp;I can't modify parsedxml=20
source.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I&nbsp;have to do all the ascii to =
unicode=20
conversion in internal python script, not even in external =
methods.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>example: </FONT></DIV>
<DIV>consider that xml, stored under zope as <EM>xmlfile</EM>:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&lt;?xml version=3D"1.0"=20
encoding=3D"iso-8859-1"?&gt;&lt;control&gt;<BR>&lt;utilisateur =
type=3D"facturation"=20
qualite=3D"2"&gt;<BR>&lt;nom=20
titre=3D"M"&gt;Bonn=E9&lt;/nom&gt;<BR>&lt;prenom&gt;Jean&lt;/prenom&gt;=20
&lt;telmobile&gt;0645237379&lt;/telmobile&gt;<BR>&lt;email&gt;albert@fia.=
fr&lt;/email&gt;&lt;/utilisateur&gt;<BR>&lt;adresse=20
type=3D"facturation"&gt;<BR>&lt;rue1&gt;14 rue d=92avant=E9&lt;/rue1&gt; =

<BR>&lt;cpostal&gt;75015&lt;/cpostal&gt; =
<BR>&lt;ville&gt;PARIS&lt;/ville&gt;=20
&lt;/adresse&gt;<BR>&lt;adresse type=3D"livraison"&gt;<BR>&lt;rue1&gt;14 =
rue=20
d=92apr=E8s&lt;/rue1&gt; <BR>&lt;cpostal&gt;75015&lt;/cpostal&gt;=20
<BR>&lt;ville&gt;PARIS&lt;/ville&gt;=20
&lt;/adresse&gt;<BR>&lt;infocommande&gt;<BR>&lt;montant=20
devise=3D"EUR"&gt;88&lt;/montant&gt; =
<BR>&lt;refid&gt;Cmde-004&lt;/refid&gt;=20
<BR>&lt;siteid&gt;112&lt;/siteid&gt;&lt;/infocommande&gt;&lt;/control&gt;=
<BR></DIV>
<DIV>there is an accentued character at line 3.</DIV>
<DIV>this python script raises exception:</DIV>
<DIV>&nbsp;</DIV>
<DIV>for items in =
container.xmlfile.documentElement.childNodes:<BR>&nbsp;&nbsp;=20
print items<BR>return =
printed<BR><STRONG><STRONG></STRONG></STRONG></DIV>
<DIV><STRONG><STRONG>Error Type: UnicodeError</STRONG><BR><STRONG>Error =
Value:=20
ASCII encoding error: ordinal not in =
range(128)</STRONG><BR></STRONG></DIV>
<DIV>how to proceed to print that without modify the parsedxml source =
nor the=20
site.py file?</DIV><BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_000D_01C35DA1.B98ED7D0--



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

_______________________________________________
Parsed-XML-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/parsed-xml-dev

--===============90053145367332244==--