xml.dom.minidom - parseString - How to avoid ExpatError?
John Abel
jabel at plus.net
Thu Oct 27 04:10:55 EDT 2005
Have a look on:
http://xml.com/pub/a/98/10/guide0.html?page=4#WELLFORMED
Explains it better then I can.
J
Gregory Piñero wrote:
> 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 <mailto: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  , 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>
> > <mailto: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
> <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
> <http://mail.python.org/mailman/listinfo/python-list>
>
>
>
>
> --
> Gregory Piñero
> Chief Innovation Officer
> Blended Technologies
> (www.blendedtechnologies.com <http://www.blendedtechnologies.com>)
More information about the Python-list
mailing list