enumerate XML tags (keys that will become headers) along with text (values) and write to CSV in one row (as opposed to "stacked" values with one header)
Denis McMahon
denismfmcmahon at gmail.com
Mon Jun 29 20:54:22 EDT 2015
On Sun, 28 Jun 2015 17:07:00 -0700, Ned Batchelder wrote:
> On Sunday, June 28, 2015 at 5:02:19 PM UTC-4, Denis McMahon wrote:
>> <things>
>> <thing>string 3</thing>
>> <thing>string 2</thing>
>> <thing>string 1</thing>
>> </things>
>> Each <thing> is just a member of the collection things, the xml does
>> not contain sufficient information to state that <things> is an ordered
>> collection containing a specific sequence of <thing>.
>
> You are right that XML does not specify that <things> is an ordered
> collection.
> But XML does preserve the order of the children. There are many XML
> schema that rely on XML's order-preserving nature.
But what we *don't* know is whether the order of the umpteen identical
tags in the XML has any significance in terms of the original data,
although the OP seems intent on assigning some significance to that order
without any basis for doing so.
Consider the following tuple:
t = (tuplemember_1, tuplemember_2, .... tuplemember_n)
Can we safely assume that if the tuple is ever converted to xml, either
now or at some future date using whatever the code implementation is
then, that the order of the items will be preserved:
<tuple>
<item>tuplemember_1</item>
<item>tuplemember_2</item>
....
<item>tuplemember_n/item>
</tuple>
And if we're reading that xml structure at some point in the future, is
it safe to assume that the tuple members are in the same order in the xml
as they were in the original tuple?
For sanity <item> should have an attribute specifying the sequence of the
item in it's tuple.
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list