[Tutor] trying to parse an xml file

spir denis.spir at gmail.com
Sat Dec 14 16:03:09 CET 2013


On 12/14/2013 03:29 PM, bruce wrote:
> Hi.
>
> Looking at a file -->>
> http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml
>
> The file is generated via online/web url, and appears to be XML.
>
> However, when I use elementtree:
>    document = ElementTree.parse( '/apps/parseapp2/testxml.xml' )
>
> I get an invalid error : not well-formed (invalid token):
>
> I started to go through the file, to "remove" offending chars, but
> decided there has to be a better approach. I also looked at the
> underlying url/page to see what it's doing with the javascript to
> parse the XML.
>
>
> Anyone have any python suggestions as to how to proceed to parse out the data!

You do not tell us what you actually want to do. Since the input is invalid (as 
XML), obviously you cannot parse it (as XML). So what?
Also you do not reproduce the error message. How are we to guess what and why 
and how it is invalid? If this is relevant to help you, see question above. If 
not, then why do you mention this error at all?

Denis


More information about the Tutor mailing list