Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4155

Re: ElementTree XML parsing problem

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <philip@semanchuk.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parser': 0.05; 'ascii': 0.07; 'character,': 0.07; 'unexpected': 0.07; 'subject:parsing': 0.09; 'to:name:python list': 0.09; 'utf-8': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'already.': 0.16; 'bye': 0.16; 'editor,': 0.16; 'non-standard': 0.16; 'observations': 0.16; 'received:mindspring.com': 0.16; 'subject:XML': 0.16; '27,': 0.19; 'header:In-Reply-To:1': 0.22; 'column': 0.22; 'file,': 0.22; 'parse': 0.23; 'subject:problem': 0.25; 'xml': 0.26; "i'm": 0.26; 'error': 0.29; 'stops': 0.31; 'second': 0.31; 'to:addr:python- list': 0.32; 'record': 0.34; 'using': 0.34; 'file': 0.35; 'apr': 0.38; 'but': 0.38; 'mike': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'add': 0.39; 'received:24': 0.39; 'would': 0.40; 'philip': 0.60; 'header:Message-Id:1': 0.62; 'saving': 0.72; '(id': 0.84; 'received:69.73': 0.84
Content-Type text/plain; charset=iso-8859-1
Mime-Version 1.0 (Apple Message framework v1084)
Subject Re: ElementTree XML parsing problem
From Philip Semanchuk <philip@semanchuk.com>
In-Reply-To <ip9n72$ol6$1@dont-email.me>
Date Wed, 27 Apr 2011 15:32:55 -0400
Content-Transfer-Encoding quoted-printable
References <ip9n72$ol6$1@dont-email.me>
To Python list <python-list@python.org>
X-Mailer Apple Mail (2.1084)
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - deimos.nocdirect.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - semanchuk.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.905.1303932786.9059.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 82.94.164.166
X-Trace 1303932786 news.xs4all.nl 81478 [::ffff:82.94.164.166]:45610
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4155

Show key headers only | View raw


On Apr 27, 2011, at 2:26 PM, Mike wrote:

> I'm using ElementTree to parse an XML file, but it stops at the second record (id = 002), which contains a non-standard ascii character, ä. Here's the XML:
> 
> <?xml version="1.0"?>
> <snapshot time="Mon Apr 25 08:47:23 PDT 2011">
> <records>
> <record id="001" education="High School" employment="7 yrs" />
> <record id="002" education="Universität Bremen" employment="3 years" />
> <record id="003" education="River College" employment="5 yrs" />
> </records>
> </snapshot>
> 
> The complaint offered up by the parser is
> 
> Unexpected error opening simple_fail.xml: not well-formed (invalid token): line 5, column 40

You've gotten a number of good observations & suggestions already. I would add that if you're saving your XML file from a text editor, make sure you're saving it as UTF-8 and not ISO-8859-1 or Win-1252. 


bye
Philip

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

ElementTree XML parsing problem Mike <Mike@invalid.invalid> - 2011-04-27 11:26 -0700
  Re: ElementTree XML parsing problem Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-04-27 14:41 -0400
  Re: ElementTree XML parsing problem Neil Cerutti <neilc@norwich.edu> - 2011-04-27 19:24 +0000
    Re: ElementTree XML parsing problem Mike <Mike@invalid.invalid> - 2011-04-27 13:43 -0700
  Re: ElementTree XML parsing problem Philip Semanchuk <philip@semanchuk.com> - 2011-04-27 15:32 -0400
  Re: ElementTree XML parsing problem Hegedüs Ervin <airween@gmail.com> - 2011-04-27 21:33 +0200
    Re: ElementTree XML parsing problem Mike <Mike@invalid.invalid> - 2011-04-27 13:32 -0700
  Re: ElementTree XML parsing problem Stefan Behnel <stefan_ml@behnel.de> - 2011-04-28 07:57 +0200
  Re: ElementTree XML parsing problem Ervin Hegedüs <airween@gmail.com> - 2011-04-28 08:24 +0200

csiph-web