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


Groups > comp.lang.python > #28170 > unrolled thread

Re: XML parser: Element ordering?

Started byStefan Behnel <stefan_ml@behnel.de>
First post2012-08-31 14:21 +0200
Last post2012-08-31 14:21 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: XML parser: Element ordering? Stefan Behnel <stefan_ml@behnel.de> - 2012-08-31 14:21 +0200

#28170 — Re: XML parser: Element ordering?

FromStefan Behnel <stefan_ml@behnel.de>
Date2012-08-31 14:21 +0200
SubjectRe: XML parser: Element ordering?
Message-ID<mailman.4008.1346415728.4697.python-list@python.org>
Florian Lindner, 31.08.2012 14:03:
> I plan to use the etree.ElementTree XML parser to parse a config file
> in which the order of the elements matter, e.g.:
> 
> <A>
> <C /><D />
> </A>
> 
> is not equal to:
> 
> <A>
> <D /><C />
> </A>
> 
> I have found different answers to the question if order matters in XML
> documents. So my question here: Does it matters (and is more or less
> guarenteed to matter in the future) for the ElementTree parser of
> python?

It matters for XML documents, so, yes, any XML parser will definitely
honour the document order (which is actually well defined for an XML document).

What you might be referring to is the case of a specific XML document
format, where the application (or sometimes specification) can explicitly
state that the element order in a given subtree has no meaning for the
semantics of the element and that therefore code must ignore the order in
which elements occur. But that won't magically make the parser ignore it
for you. That's a totally different level of abstraction and a deliberate
decision of the code that *uses* the parser.

Stefan

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web