H'mmm having decoded your "columns":
<dd><persson><name>sam</name><tel>9748</tel></persson>
1 2 3 4 5 6 7 8 9
<cat><name>frank</name></cat></dd>
10 11 12 13 14 15
I have some questions for you: How did you do that? Why did you do that? Exactly what do you want to achieve? Note that your question title is rather misleading -- "SQL tables" are merely where you have parked your peculiar representation of the data.
Here's some pseudocode to do what you want to do:
pieces = []
result = cursor.execute("select * from tags;")
for start, step, tag in result:
pieces.append((start, "<" + tag + ">"))
pieces.append((stop, "</" + tag + ">"))
result = cursor.execute("select * from pcdata;")
for pos, pcdata in result:
pieces.append((pos, pcdata))
pieces.sort()
xml_stream = "".join(piece[1] for piece in pieces)
your_file_object.write(xml_stream)
In answer to the question about whether the above would put the "positions" in the output stream: No it won't; the following snippet shows it working. The positions are used only to get the soup sorted into the correct order. In the "join", piece[0] refers to the position, but it isn't used, only piece[1] which is the required text.
>>> pieces
[(3, '<name>'), (4, 'sam'), (5, '</name>')]
>>> ''.join(piece[1] for piece in pieces)
'<name>sam</name>'
Relenting on the SQL comment-question:
Although shown with SQLite, this is bog-standard SQL. If your database doesn't grok || as the concatenation operator, try +.
Question that you forgot to ask: "How do I get a <?xml blah-blah ?> thingie up the front?". Answer: See below.
console-prompt>sqlite3
SQLite version 3.6.14
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table tags (start int, stop int, tag text);
sqlite> insert into tags values(3,5,'name');
sqlite> insert into tags values(6,8,'tel');
sqlite> insert into tags values(2,9,'persson');
sqlite> insert into tags values(11,13,'name');
sqlite> insert into tags values(10,14,'cat');
sqlite> insert into tags values(1,15,'dd');
sqlite> create table pcdata (pos int, pcdata text);
sqlite> insert into pcdata values(4,'sam');
sqlite> insert into pcdata values(7,'9748');
sqlite> insert into pcdata values(12,'frank');
sqlite> select datum from (
...> select 0 as posn, '<?xml version="1.0" encoding="UTF-8"?>' as datum
...> union
...> select start as posn, '<' || tag || '>' as datum from tags
...> union
...> select stop as posn, '</' || tag || '>' as datum from tags
...> union
...> select pos as posn, pcdata as datum from pcdata
...> )
...> order by posn;
<?xml version="1.0" encoding="UTF-8"?>
<dd>
<persson>
<name>
sam
</name>
<tel>
9748
</tel>
</persson>
<cat>
<name>
frank
</name>
</cat>
</dd>
sqlite>