xslt to convert to json



INPUT I'm getting:



<table>
<source1>
<ptr>
<data name="text1">20431</data>
<data name="text2">collins</data>
<data name="text3">20141231></data>
<data name="text4">regard</data>
</ptr>
</source1>
<source2>
<ptr>
<data name="note1">C</data>
<data name="note2">A</data>
<data name="note3">22356</data>
<data name="note4">465506</data>
<data name="note5">434562491057912</data>
<data name="note6">milk</data>
<data name="note7">dfRTA</data>
</ptr>
</source2>
<source3>
<enroll>n</enroll>
</source3>
</table>


need to convert this to json as



{
"table":
{
"source1":
{"text1":"20431",
"text2": "collins",
"text3": "20141231",
"text4" :"regard"
},
"source2":
{"note1":"20431",
"note2": "A",
"note3":"22356",
"note4":"465506",
"note5":"434562491057912",
"note6":"milk",
"note7":"dfRTA"
}
}}


How to convert using xsl any generic one instead of matching on each attribute name. Any one has the stylesheet which will do the above transformation


No comments:

Post a Comment