SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 How to transform NESTED SETS to XML?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mr_sol
Starting Member

Austria
2 Posts

Posted - 10/14/2010 :  01:01:06  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
2886 Posts

Posted - 10/14/2010 :  01:35:07  Show Profile  Visit jezemine's Homepage  Reply with Quote
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

Austria
2 Posts

Posted - 10/14/2010 :  03:26:40  Show Profile  Reply with Quote
MySQL is not a dogme. A query for sql server is running to.....
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000