Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.048 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'xml,': 0.05; 'element': 0.07; 'nested': 0.07; 'subject:fields': 0.09; 'subject:parsing': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nesting': 0.16; 'preserve': 0.16; 'subject:XML': 0.16; 'email addr:python.org,': 0.16; 'wrote:': 0.18; 'later': 0.20; 'not,': 0.20; 'parse': 0.24; 'initial': 0.24; 'post': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'specifically': 0.29; 'am,': 0.29; 'xml': 0.29; 'message-id:@mail.gmail.com': 0.30; 'software,': 0.31; 'depth': 0.31; 'file': 0.32; 'quite': 0.32; 'subject:with': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'replies': 0.36; 'list': 0.37; 'being': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'mailing': 0.39; 'called': 0.40; 'even': 0.60; 'read': 0.60; 'first': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.64; 'email name:python-list': 0.65; '26,': 0.68; 'groups.': 0.74; 'off,': 0.84; 'carries': 0.91; 'on?': 0.91; 'fight': 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 :content-type; bh=VvRCPlAdoXMLnXudR7y+1EK2nLnjL3OJDc6P7yZPev8=; b=mf0qEF7169w9PBsgeDQAlZ+4bClTWwcUKejkVrvrxrwwSH1wQFbEhU4mG5BFWHezm7 CM3KVx3Kjd2LkVVieCJehvOZzBpsvCazwp+NCr/LWzDuqv5QjUkl425wFtaGwN60wbXu YC9W5vO/NzlZoKFKHkrN0RThyGrb8nO2u7cmo3Fj9OvOmivpBiuXnPuF8b/vJcj59NHi 01jcmmtevHV8nHXi2zYaxVMmrPYJR4CQtvVBRqygzNiJw1k1lgQkQqRNEVW1ShEsCXsg E+4RS2hdWmYYCbZiIlnY0ADmsjTaByFmyggx55QF5w5xuoMs6XzwdCylsDsA362DSLOH NmrQ== MIME-Version: 1.0 X-Received: by 10.69.31.1 with SMTP id ki1mr10181218pbd.124.1385418644106; Mon, 25 Nov 2013 14:30:44 -0800 (PST) In-Reply-To: References: Date: Tue, 26 Nov 2013 09:30:44 +1100 Subject: Re: parsing nested unbounded XML fields with ElementTree From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385418647 news.xs4all.nl 15994 [2001:888:2000:d::a6]:38349 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60457 On Tue, Nov 26, 2013 at 9:22 AM, Larry.Martell@gmail.com wrote: > I have an XML file that has an element called "Node". These can be nested to any depth and the depth of the nesting is not known to me. I need to parse the file and preserve the nesting. For exmaple, if the XML file had: > > > > > > First off, please clarify: Are there five corresponding tags later on? If not, it's not XML, and nesting will have to be defined some other way. Secondly, please get off Google Groups. Your initial post is malformed, and unless you specifically fight the software, your replies will be even more malformed, to the point of being quite annoying. There are many other ways to read a newsgroup, or you can subscribe to the mailing list python-list@python.org, which carries the same content. ChrisA