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


Groups > comp.lang.python > #32435

Re: problems with xml parsing (python 3.3)

Received by 10.224.223.14 with SMTP id ii14mr16476420qab.3.1351551284007; Mon, 29 Oct 2012 15:54:44 -0700 (PDT)
Received by 10.236.115.33 with SMTP id d21mr2979207yhh.12.1351551283974; Mon, 29 Oct 2012 15:54:43 -0700 (PDT)
Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!209.85.216.88.MISMATCH!e17no13327948qar.0!news-out.google.com!gf5ni2985800qab.0!nntp.google.com!e17no13327944qar.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Mon, 29 Oct 2012 15:54:43 -0700 (PDT)
In-Reply-To <97d8de0d-3daa-49be-a91f-c65fc8a9019f@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=79.247.230.4; posting-account=GLVKZwoAAAAZ4HENzI_dniGFTlVL3cv9
NNTP-Posting-Host 79.247.230.4
References <97d8de0d-3daa-49be-a91f-c65fc8a9019f@googlegroups.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <07d64ccf-3b8a-4ffa-baa2-5fb566a8a715@googlegroups.com> (permalink)
Subject Re: problems with xml parsing (python 3.3)
From jannidis@gmail.com
Injection-Date Mon, 29 Oct 2012 22:54:44 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:32435

Show key headers only | View raw


Am Sonntag, 28. Oktober 2012 03:27:14 UTC+1 schrieb jann...@gmail.com:
> Hello all, 
> 
> 
> 
> I am new to Python and have a problem with the behaviour of the xml parser. Assume we have this xml document:
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <bibliography>
> 
>     <entry>
> 
>             Title of the first book.
> 
>         </entry>
> 
>         <entry>
> 
>             <coauthored/>
> 
> Title of the second book.
> 
>         </entry>
> 
> </bibliography>    
> 
> 
> 
> 
> 
> If I now check for the text of all 'entry' nodes, the text for the node with the empty element isn't shown
> 
> 
> 
> 
> 
> 
> 
> import xml.etree.ElementTree as ET
> 
> tree = ET.ElementTree(file='test.xml')
> 
> root = tree.getroot()
> 
> resultSet = root.findall(".//entry")
> 
> for r in resultSet:
> 
> 	print (r.text)

thanks a lot for your answer. as I am looking for a tool to teach using xml in programming it is a pity that this modul implements a very idiosyncratic view on xml data, but dom and sax are out there too, so I will look at them. 

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


Thread

problems with xml parsing (python 3.3) jannidis@gmail.com - 2012-10-27 19:27 -0700
  Re: problems with xml parsing (python 3.3) jannidis@gmail.com - 2012-10-27 19:30 -0700
  Re: problems with xml parsing (python 3.3) MRAB <python@mrabarnett.plus.com> - 2012-10-28 03:08 +0000
  Re: problems with xml parsing (python 3.3) Dieter Maurer <dieter@handshake.de> - 2012-10-28 08:30 +0100
  Re: problems with xml parsing (python 3.3) jannidis@gmail.com - 2012-10-29 15:54 -0700
  Re: problems with xml parsing (python 3.3) jannidis@gmail.com - 2012-10-30 05:37 -0700

csiph-web