xml.dom.minidom - parseString - How to avoid ExpatError?

Gregory Piñero gregpinero at gmail.com
Wed Oct 26 13:20:03 EDT 2005


What do you mean by well-formed? What is required to make XML well formed?

-Greg


On 10/26/05, John Abel <jabel at plus.net> wrote:
>
> Try this page:
>
> http://docs.python.org/lib/module-xml.sax.saxutils.html
>
> I've just tried the code, taking out the &nbsp, and adding in the belo,
> as the XML is not well formed, otherwise.
>
> <?xml version="1.0" encoding="ISO-8859-15"?>
>
> The code then works.
>
> HTH
>
> J
>
> Gregory Piñero wrote:
>
> > Should I try some sort of XML group instead? I'm still stuck on this.
> >
> > -Greg
> >
> >
> > On 10/25/05, *Gregory Piñero* <gregpinero at gmail.com
> > <mailto:gregpinero at gmail.com>> wrote:
> >
> > Hi guys,
> >
> > I was hoping some XML expert could help me make this code work.
> > Below is sample code with sample XML similar to what I'm dealing with.
> >
> > How can I make the weird characters in the XML not break the
> > parser? I'll do anything to make this work!
> >
> > (Note: the   broke my parser yesterday but doesn't seem to in
> > this sample code) But really I'm looking for solutions that will
> > handles lots
> > of unusual characters.
> >
> > Much thanks,
> >
> > Greg
> >
> >
> > <code>
> > from xml.dom.minidom import parseString
> > data="""
> > <blog>
> > <post>
> > This is sample problem text.   £500.00
> > </post>
> > </blog>
> > """
> > myDOM=parseString(data)
> > </code>
> >
> > <error>
> > Traceback (most recent call last):
> > File
> >
> "C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> > line 307, in RunScript
> > debugger.run(codeObject, __main__.__dict__, start_stepping=0)
> > File
> > "C:\Python23\Lib\site-packages\pythonwin\pywin\debugger\__init__.py",
> > line 60, in run
> > _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
> > File
> > "C:\Python23\Lib\site-packages\pythonwin\pywin\debugger\debugger.py",
> > line 631, in run
> > exec cmd in globals, locals
> > File "C:\Documents and Settings\Gregory\My Documents\Python\xml
> > help\xmlproc.py", line 9, in ?
> > myDOM=parseString(data)
> > File "C:\Python23\lib\xml\dom\minidom.py", line 1929, in parseString
> > return expatbuilder.parseString(string)
> > File "C:\Python23\lib\xml\dom\expatbuilder.py", line 940, in
> > parseString
> > return builder.parseString(string)
> > File "C:\Python23\lib\xml\dom\expatbuilder.py", line 223, in
> > parseString
> > parser.Parse(string, True)
> > ExpatError: undefined entity: line 4, column 29
> > </error>
> >
> >
> >
> > --
> > Gregory Piñero
> > Chief Innovation Officer
> > Blended Technologies
> > (www.blendedtechnologies.com <http://www.blendedtechnologies.com> <
> http://www.blendedtechnologies.com>)
> >
> >
> >
> >
> > --
> > Gregory Piñero
> > Chief Innovation Officer
> > Blended Technologies
> > (www.blendedtechnologies.com <http://www.blendedtechnologies.com> <
> http://www.blendedtechnologies.com>)
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com <http://www.blendedtechnologies.com>)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051026/5e2706f7/attachment.html>


More information about the Python-list mailing list