Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Transaction History XML question...

Chance Takashi
Inimitable
Join date: 22 Feb 2006
Posts: 25
07-27-2006 09:13
Just to be clear, the xml file I'm talking about is the one I get to via SL Homepage->My Account->Transactions->Set Date Range->;(xml)

The xml format looks like:

CODE
<?xml version="1.0" ?>
<transactions>
<transaction_58887076>
<id>58887076</id>
<type>Give Inventory</type>
<description></description>
<payment>0</payment>
<time>2006-07-26 22:33:49</time>
<resident>xxx xxxx</resident>
<end_balance>-</end_balance>
</transaction_58887076>
<transaction_58876388>
<id>58876388</id>
<type>Upload Charge</type>
<description></description>
<payment>10</payment>
<time>2006-07-26 21:55:26</time>
<resident>SYSTEM</resident>
<end_balance>xxx</end_balance>
</transaction_58876388>
<transaction_58812627>
<id>58812627</id>
<type>Object Sale</type>
<description>Product X</description>
<deposit>xxx</deposit>
<time>2006-07-26 18:26:18</time>
<resident>xxxx</resident>
<end_balance>xxx</end_balance>
</transaction_58812627>
</transactions>


My question is this. Is there a specific reason that the elements contained within the transactions element are "transaction_{some ID number}" instead of just "transaction"?

The reason I ask is that XML-wise, each transaction_{blah} element is an utterly different thing, not the same type of thing with different data. The ID is already an element of the transaction_{blah} element, and it could be easily added as an attribute:

CODE
<transaction id="123456">...</transaction>


Now, it's no problem to build an xml parser that understands to drop the _{blah} from the tag to determine how to handle things, but before I do, I was just curious as to the rationale for the way the xml is structured.
Torley Linden
Enlightenment!
Join date: 15 Sep 2004
Posts: 16,530
07-28-2006 11:23
Asking about this...
_____________________
Morpheus Linden
Lost in the Dreaming
Join date: 29 Jun 2006
Posts: 9
07-28-2006 11:52
From: Chance Takashi
Is there a specific reason that the elements contained within the transactions element are "transaction_{some ID number}" instead of just "transaction"?


Yeah, I wasn't very happy about it when I created it that way, but it was basically a matter of expediency and assuming that anyone parsing this data would be smart enough to to strip apart the piece... It's why I put the underscore in -- to give you somthing to split the sting on :).

To generate this data, we first put the data into a php array, and use a php library to generate the xml from that array. As you may know, all PHP arrays are hashes with either implicit keys (0,1,2...) or explicit ones ($key->$value). Assigning a new transaction to the arrayname['transaction'] would overwrite the existing transaction, and you'd end up with only one transaction. Assigning it to just arrayname[] would force the implicit keys so you'd get
CODE

<transactions>
<0>
...transaction details
</0>
<1>
...etc...
</transactions>


So, I compromised as described above.