Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50430
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fabiosantosart@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:error': 0.03; 'output': 0.05; 'tree': 0.05; 'column': 0.07; 'parser': 0.07; 'lines.': 0.09; 'xml.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'sections': 0.14; '2.7.3': 0.16; 'angled': 0.16; 'brackets': 0.16; 'brackets.': 0.16; 'dots': 0.16; 'parser.': 0.16; 'preserve': 0.16; 'slash': 0.16; 'statements,': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'examples': 0.20; 'fit': 0.20; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'of.': 0.24; 'parse': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'skip:" 40': 0.26; 'tutorials': 0.26; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'character': 0.29; 'raise': 0.29; 'xml': 0.29; "doesn't": 0.30; 'errors': 0.30; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; 'too.': 0.31; '"",': 0.31; 'bunch': 0.31; 'fault': 0.31; 'file': 0.32; 'skip:c 30': 0.32; 'summary': 0.32; '(most': 0.33; 'skip:& 30': 0.33; 'sense': 0.34; 'could': 0.34; 'basic': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'html,': 0.36; 'in.': 0.36; 'tech': 0.36; 'ubuntu': 0.36; 'thanks': 0.36; 'wrong': 0.37; 'skip:& 10': 0.38; 'feed': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'subject:can': 0.39; 'skip:p 20': 0.39; 'space': 0.40; 'tag': 0.61; 'numbers': 0.61; 'first': 0.61; 'show': 0.63; 'stand': 0.64; 'url:p': 0.64; 'latest': 0.67; 'url:0': 0.67; 'finance': 0.70; 'url:a': 0.72; 'cut': 0.74; 'jul': 0.74; 'url:jpg': 0.83; '10:04,': 0.84; 'experiment': 0.84; 'href="': 0.84; 'to:addr:bluewin.ch': 0.84; 'url:fi': 0.84; 'url:l': 0.97; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=JwTr+yrKL/UVEopUNQCsT0wgHUSZDsKQAB4FwP+RJi0=; b=qLDpkMHrrLJQEPb/D4uEUvwBSL3Y9fe4LCgkpg7BUwEX8HegeUlFzqSStIsOWEgZ50 NfsbpVvNMBnpm2ejsYmSgpS26t8BLByFagSwECnFqZujGfLJMzeSrO4YuaCGqtRayZVh UMqsfKEO9+asF0gizKTGV3ry2BDT4R31TCO2O88RFPnQYhSdpEuv2DuAVwgrmnDFD0YK xM6AKDxaulugUPOQegNQLqdblWuW41KcTTm731wVA6YydzTi1YHB7h5SXTe9Jyenbehc 61BwQ9raTm/EWUArjjsDS1AxWYrs0Ne/p4rixcH0NGtIKjBJNNHPdOy/oDrjARBntBup covw== |
| MIME-Version | 1.0 |
| X-Received | by 10.229.141.10 with SMTP id k10mr7015064qcu.44.1373533684663; Thu, 11 Jul 2013 02:08:04 -0700 (PDT) |
| In-Reply-To | <51DE73E4.6040007@bluewin.ch> |
| References | <51DE73E4.6040007@bluewin.ch> |
| Date | Thu, 11 Jul 2013 10:08:04 +0100 |
| Subject | Re: ElementTree: can't figure out a mismached-tag error |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| To | "F.R." <anthra.norell@bluewin.ch> |
| Content-Type | multipart/alternative; boundary=90e6ba3098a85c8e9d04e138bbfd |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.4578.1373533692.3114.python-list@python.org> (permalink) |
| Lines | 171 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1373533692 news.xs4all.nl 15979 [2001:888:2000:d::a6]:33823 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50430 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 11 Jul 2013 10:04, "F.R." <anthra.norell@bluewin.ch> wrote:
>
> Hi all,
>
> I haven't been able to get up to speed with XML. I do examples from the
tutorials and experiment with variations. Time and time again I fail with
errors messages I can't make sense of. Here's the latest one. The url is "
http://finance.yahoo.com/q?s=XIDEQ&ql=0". Ubuntu 12.04 LTS, Python 2.7.3
(default, Aug 1 2012, 05:16:07) [GCC 4.6.3]
>
> >>> import xml.etree.ElementTree as ET
> >>> tree = ET.parse('q?s=XIDEQ') # output of wget
http://finance.yahoo.com/q?s=XIDEQ&ql=0
> Traceback (most recent call last):
> File "<pyshell#69>", line 1, in <module>
> tree = ET.parse('q?s=XIDEQ')
> File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1183, in parse
> tree.parse(source, parser)
> File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 656, in parse
> parser.feed(data)
> File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1643, in feed
> self._raiseerror(v)
> File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1507, in
_raiseerror
> raise err
> ParseError: mismatched tag: line 9, column 2
>
> Below first nine lines. The line numbers and the following space are
hand-edited in. Three dots stand for sections cut out to fit long lines.
Line 6 is a bunch of "meta" statements, all of which I show on a separate
line each in order to preserve the angled brackets. On all lines the angled
brackets have been preserved. The mismatched character is the slash of the
closing tag </head>. What could be wrong with it? And if it is, what about
fault tolerance?
>
> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD . . . /strict.dtd">
> 2 <html lang="en-US">
> 3 <head><meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
> 4 <title>XIDEQ: Summary for EXIDE TECH NEW- Yahoo! Finance</title>
> 5 <meta name="description" xml:space="default" content="View the basic
XIDEQ . . .
> 6 . . . other companies."><meta name="keywords" content="XIDEQ, EXIDE
TECH . . .">
> <meta property="fb:app_id" content="118155468215844">
> <meta property="fb:admins" content="503762770,100001149693905">
> <meta property="og:type" content="company">
> <meta property="og:site_name" content="Yahoo! Finance">
> <meta property="og:title" content="Exide Technologies">
> <meta property="og:image" content="http://l.yimg.com/a/p/fi/31/09/00.jpg
">
> <meta property="og:url" content="http://finance.yahoo.com/q?s=XIDEQ">
> <meta property="og:description" content="View the basic XIDEQ . . .
> 7 other companies."><link rel="canonical" href="
http://finance.yahoo.com/q?s=XIDEQ">
> 8 <link rel="stylesheet" href="http://l.yimg.com/zz/ . . .
type="text/css">
> 9 </head>
> ^
> Mismatch!
>
> Thanks for suggestions
>
> Frederic
That is not XML. It is HTML. You get a mismatched tag because the <link>
tag doesn't need closing in HTML, but in XML every single tag needs closing.
Use an HTML parser. I strongly recommend BeautifulSoup but I think etree
has an HTML parser too. I am not sure..
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: ElementTree: can't figure out a mismached-tag error Fábio Santos <fabiosantosart@gmail.com> - 2013-07-11 10:08 +0100
Re: ElementTree: can't figure out a mismached-tag error fronagzen@gmail.com - 2013-07-11 02:19 -0700
Re: ElementTree: can't figure out a mismached-tag error Fábio Santos <fabiosantosart@gmail.com> - 2013-07-11 11:27 +0100
csiph-web