Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 Article Discussion
 How to transform NESTED SETS to XML?

Author  Topic 

mr_sol
Starting Member

2 Posts

Posted - 2010-10-14 : 01:01:06
Hallo,

I'd need a MySQL query to transform my nested sets structure into XML. (no PHP).The Problem is how to close all tags correct.

EXAMPLE:

A[01,16]
B[02,03] C[04,13] H[14,15]
D[05,12]
E[06,07] F[08,11]
G[09,10]

<A>content A<B>content B</B><c>content C<C>content D<E>content E</E><F>content F<G>content G</G></F></D></C><H>content H</H></A>




TESTING CONTENT:

CREATE TABLE IF NOT EXISTS `tree` (
`id` int(11) NOT NULL,
`tag` varchar(100) NOT NULL,
`lft` int(11) NOT NULL,
`rgt` int(11) NOT NULL,
`desc` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


INSERT INTO `tree` (`id`, `tag`, `lft`, `rgt`, `desc`) VALUES
(1, 'A', 1, 16, 'content A'),
(2, 'B', 2, 3, 'content B'),
(3, 'C', 4, 13, 'content C'),
(4, 'D', 5, 12, 'content D'),
(5, 'E', 6, 7, 'content E'),
(6, 'F', 8, 11, 'content F'),
(7, 'G', 9, 10, 'content G'),
(8, 'H', 14, 15, 'content H');



thanks a lot for helping

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2010-10-14 : 01:35:07
might have better luck asking on a mysql forum. this one is focused on sql server.


elsasoft.org
Go to Top of Page

mr_sol
Starting Member

2 Posts

Posted - 2010-10-14 : 03:26:40
MySQL is not a dogme. A query for sql server is running to.....
Go to Top of Page
   

- Advertisement -