Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<?xml version="1.0"?>
-<DocumentElement>
-<test>
<c0>manas</c0>
<c1>100</c1>
<c2>20</c2>
<c3>33</c3>
<c4>54</c4>
 <c5>65</c5>
<c6>78</c6>
</test>
 -<test>
<c0>manasi</c0>
<c1>101</c1>
<c2>25</c2>
 <c3>76</c3>
<c4>90</c4>
<c5>12</c5>
<c6>74</c6>

</test>
 -<test>
<c0>mani</c0>
<c1>115</c1>
<c2>29</c2>
<c3>56</c3>
<c4>11</c4>
<c5>95</c5>
<c6>78</c6>
</test>
 </DocumentElement>

Console Application
For first Node Test:
manas 100 20 33
manas 54 65 78

For Second Node Test:
manasi 101 25 76
manasi 90 12 74

For Third Node Test:
mani 115 29 56
mani 11 95 78

Sir,
Aim is to split multiple number of columns .

Actually 7 columns values for First node Test like manas 100 20 33 54 65 78
My requirement is to display first column(manas) with 3 other row, again it will create a break and write like first column(manas) with next 3 columns.
Then same type it will create for second Node Test.
Then same type it will create for Third Node Test.
Posted
Updated 2-Jul-13 8:28am
v3

It sounds like you want to write a C# console app and transform your data using xsl. This is straightforward; just create a console app. Use the System.Xml and System.Xml.Xsl library namespaces.
C#
XslTransform xslt = new XslTransform();
xslt.Load("mytransform.xsl");
XPathDocument mydata = new XPathDocument("inputdata.xml");
XmlWriter writer = new XmlTextWriter(Console.Out);
xslt.Transform(mydata,null,writer, null);

Put the formatting details in the .xsl file.
 
Share this answer
 
Comments
connect2manas 2-Jul-13 14:56pm    
thanks for your answer.

kindly help me to split the below like:

-<documentelement>
-<test>
<c0>manas
<c1>100
<c2>20
<c3>33
<c4>54
<c5>65
<c6>78




- plz try to load this file.
-print the 2 values in a single row
like
manas 100
20 33
54 65
78

plz help me.
H.Brydon 2-Jul-13 15:05pm    
This looks too much like homework, which we don't do here. You need to put in some effort to learn this yourself. "Please do this for me" is not a valid request.

Have a look at xslt techniques in a book or on the web. A good reference is http://www.w3schools.com/xsl/default.asp
Hope it will solve your problem as per my understanding.

DECLARE @XML XML='<documentelement>
<test><c0>manas</c0><c1>100</c1><c2>20</c2><c3>33</c3><c4>54</c4><c5>65</c5><c6>78</c6></test>
<test><c0>manasi</c0><c1>101</c1><c2>25</c2><c3>76</c3><c4>90</c4><c5>12</c5><c6>74</c6></test>
<test><c0>mani</c0><c1>115</c1><c2>29</c2><c3>56</c3><c4>11</c4><c5>95</c5><c6>78</c6></test>
</documentelement>'
 
 Select Column1= x.value('c0[1]','varchar(100)') + ' '+ x.value('c1[1]','varchar(100)')+' ' +x.value('c2[1]','varchar(100)') +' '+x.value('c3[1]','varchar(100)'),
 Column2= x.value('c0[1]','varchar(100)') + ' '+ x.value('c4[1]','varchar(100)')+' ' +x.value('c5[1]','varchar(100)') +' '+x.value('c6[1]','varchar(100)')     
 from @XML.nodes('/DocumentElement/test') e(x)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900