XML Node Names ?

In a SQLite database, I have a Table named Heading where I store the Data Base Table Field Names and string to be displayed in the Listbox Heading (thus the Table name).

Of course, I have a main Table where I store the data to be displayed in the Listbox Rows.

The target xml data will be like:


First Name Middle Name Family Name Birth Date Birth City City Zip Birth Country Phone Number [/code]

<!-- Contents of each main Table Rows [Listbox Rows --> <rows> <Row_0> <Col_0>Emile</Col_0> <Col_1>A.</Col_1> <Col_2>Schwarz</Col_2> <Col_3>March 2, Long time ago</Col_3> <Col_4>Le Cannet</Col_4> <Col_5>06110</Col_5> <Col_6>France</Col_6> <Col_7>(01) 234 567 890</Col_7> <Row_0> <!-- Followed by as many entries as there are RecordSet in the Table --> </rows>

My question is simple: is the Rows block OK for You ? Or must I put the Column Code Names (First_Name for example) instead of Col_0 ?

XML is meant to be User Readable, but Col_0 is far shorter than First_Name and … who will read an XML file ?

What is your opinion ?

User readable doesn’t mean short
You could use a more readable

    <row id="0">
        <col id="0" field="First Name">Emile</col>
        <col id="1" field="Middle Name">A.</col>


    <col field="First Name"/>


    <row id="rowid">
        <col field="First Name" value="Emile"/>

With Xml you are free to create the document the best fulfill your needs as long it is a well formed document.

Thanks Antonio.

In a sense, the shorter file, the better file. 1978 entries looks like > 620K.
The SQLIte Data Base file is 156KB, 157KB a Tab _ Return text export: the user will choose what (s)he want.

In my (humble) opinion, they should match. That way, the human reading the file knows immediately what the column is.

My non-humble opinion is that the Row node name should be constant. Do not append the row number to it. That allows you to use XQL to get a recordset (technically nodelist, but the same thing) of all the rows, or all the First Names even.


XML has a query language modeled after SQL. Structure your XML to take advantage of it.

Hi Tim.

Your answer… why do I use an appended Row # (using the loop indice) ? Good question. I think either (or both) it was natural to do it AND so I do have distinct Row definitions in the xml. I probably feel that entries have to be unique.

The code to add a unique number is simple: "Row_" + Str(LoopIdx) … this is far different than if I had to wrote a complex code… I probably ask me question like why ? :wink:

I just spend minutes to read some xml files I have in my hard disk and… you are right. many files use the same strings for the xml keywords to hold different data. If this is the norm (usage), I will follow it.

Yes, that is standard practice.

XML is the base for a descriptive language for your data. Is up to you make it or respect some other constrains.
The only rule is that the document has to be well formed.
It will be neve shorter than a SQLIte or tab separated file.

The reason for use node values versus attributes is more historical than structural.
Dom reader where less common and in a event reader was easier to read node value than attribute.

With a DOM reader maybe is easier to read an attribute than a node value (think the code you have to write for these operation in Xojo), with attribute the Doc will be shorter (no closing tag), will be easier to analyze or transform with XQL (or XSLT) and you can use a notation closer to an OOP: a tag represent an object, the attributes represent the properties and the sub nodes represent sub objects.

Thanks Tim, Antonio.

I had the bad idea to make the read / write for both xml and json using a TextArea and a Listbox to be sure everything is OK, then modify my own code to read / export from SQLite database into xml (& json). When the time to make the real code I started to have troubles, many troubles.

For xml, to be able to do the encoding as I wrote earlier, I had to go back to Real Studio 2012 lr example… Even w3school have a strange coding examples and talk exclusively to web browser to web server (and back) use.

At last, I checked earlier this evening (around 3, I awoken from a nightmare…), I get an eye on my json generation and… I just do what Tim advice was: I used the column name as the left part of ‘:’, the real data on the right par (json array). Fun.