i have a sql table
username level1 level2 level3 level4 level5 level6 level7
ane |
HR |
HR3 |
HR31 |
NULL |
NULL |
NULL |
NULL |
ane |
HR |
HR3 |
HR32 |
HR321 |
NULL |
NULL |
NULL |
ane |
HR |
HR3 |
HR32 |
HR322 |
NULL |
NULL |
NULL |
ane |
HR |
HR3 |
HR33 |
NULL |
NULL |
NULL |
NULL |
ane |
HR |
HR4 |
NULL |
NULL |
NULL |
NULL |
NULL |
ane |
Payroll |
NULL |
NULL |
NULL |
NULL |
NULL |
NULL |
ane |
Production |
CDL |
NULL |
NULL |
NULL |
NULL |
NULL |
ane |
Production |
Quality Control |
Aging |
NULL |
NULL |
NULL |
NULL |
ane |
Production |
Quality Control |
Expiry Summary |
NULL |
NULL |
NULL |
NULL |
ane |
Production |
Stock |
Material |
CBA Stock |
NULL |
NULL |
NULL |
ane |
Production |
Stock |
Material |
Factory Stock |
NULL |
NULL |
NULL |
ane |
Production |
Stock |
Material |
m3 |
NULL |
NULL |
NULL |
ane |
Production |
Stock |
stock2 |
NULL |
NULL |
NULL |
NULL |
ane |
Production |
Stock |
stock3 |
NULL |
NULL |
NULL |
NULL |
and i want to generate xml file like this :
<UserName text="ane">
<Level1 text="HR">
<Level2 text="HR2"></Level2>
<Level2 text="HR3">
<Level3 text="HR31"></Level3>
<Level3 text="HR32">
<Level4 text="HR321"></Level4>
<Level4 text="HR322"></Level4>
</Level3>
<Level3 text="HR33"></Level3>
</Level2>
<Level2 text="HR4"></Level2>
</Level1>
<Level1 text="Payroll"/>
<Level1 text="Production">
<Level2 text="CDL"></Level2>
<Level2 text="Quality Control">
<Level3 text="Aging"></Level3>
<Level3 text="Expiry Summary"></Level3>
</Level2>
<Level2 text="Stock">
<Level3 text="Material">
<Level4 text="CBA Stock"></Level4>
<Level4 text="Factory Stock"></Level4>
<Level4 text="m3"></Level4>
</Level3>
<Level3 text="stock2"></Level3>
<Level3 text="stock3"></Level3>
</Level2>
</Level1>
</UserName>
please help