Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89952
| References | <d429abb8-2b17-4235-9eea-27a9a6f1ec9f@googlegroups.com> |
|---|---|
| Date | 2015-05-05 19:44 +1000 |
| Subject | Re: Is it normal to cry when given XML? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.118.1430819082.12865.python-list@python.org> (permalink) |
On Tue, May 5, 2015 at 7:28 PM, Sayth Renshaw <flebber.crue@gmail.com> wrote: > Hi > > Just checking if the reaction to cry when given XML is normal. It's not unsurprising, especially with bad XML structures. > I thought maybe I am approaching it all wrong, using lxml largely or some xquery to club it into submission. > > See the usual goal is just to take the entire XML and push it into a database. or in future experiment with Mongo or Hdf5 . > > See its never basic xml, usually comes from some database with a walk of tables and strange relationships. > > Am I doing it wrong is there a simple way I am missing? Generally, I work with XML only as a transport layer; and most of the time, it's for a document structure that would be better served by JSON anyway. (This may mean that I have an unfairly negative view of XML, but it's extremely common.) My usual technique is to parse it into something native (usually a dictionary - and probably the same structure that the other end constructed the XML from), then work with that. For example, querying the ePond API [1] gives back a pile of XML data, so I might have a single function that performs a synchronous HTTP query, takes the response body, parses it using a fairly generic XML parser like lxml, then digs three levels into the resulting tree to pull out the bit that actually matters, leaving behind all the framing and stuff. The less time you spend with actual XML, the better. XML is not the answer. ChrisA [1] A completely fictional web site, of course, and in no way implying that I have had a frustrating time with a well-known online sales/auction company.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is it normal to cry when given XML? Sayth Renshaw <flebber.crue@gmail.com> - 2015-05-05 02:28 -0700
Re: Is it normal to cry when given XML? Chris Angelico <rosuav@gmail.com> - 2015-05-05 19:44 +1000
Re: Is it normal to cry when given XML? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-05 20:04 +1000
Re: Is it normal to cry when given XML? Adam Tauno Williams <awilliam@whitemice.org> - 2015-05-05 06:20 -0400
Re: Is it normal to cry when given XML? Sayth Renshaw <flebber.crue@gmail.com> - 2015-05-05 05:03 -0700
Re: Is it normal to cry when given XML? Tim <jtim.arnold@gmail.com> - 2015-05-05 06:05 -0700
Re: Is it normal to cry when given XML? Michael Torrie <torriem@gmail.com> - 2015-05-05 10:54 -0600
Re: Is it normal to cry when given XML? Grant Edwards <invalid@invalid.invalid> - 2015-05-05 16:58 +0000
Re: Is it normal to cry when given XML? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-05-05 21:03 -0400
Re: Is it normal to cry when given XML? Emile van Sebille <emile@fenx.com> - 2015-05-05 16:04 -0700
Re: Is it normal to cry when given XML? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-06 00:35 +0100
Re: Is it normal to cry when given XML? Chris Angelico <rosuav@gmail.com> - 2015-05-06 10:07 +1000
Re: Is it normal to cry when given XML? Rustom Mody <rustompmody@gmail.com> - 2015-05-05 17:19 -0700
Re: Is it normal to cry when given XML? Chris Angelico <rosuav@gmail.com> - 2015-05-06 10:29 +1000
csiph-web