How to split delimited string to XML node Tree

dmiftah

New Member
OK upfront, I'm a newb on PHP and Java, however trying to refresh my coding after journeying into management for the past ten years.I have a table in the form:\[code\]heading1_sub1_element1 = data1heading1_sub1_element2 = data2heading1_sub1_element3 = data3heading1_sub2_element1 = data4heading1_sub2_element2 = data5heading1_sub2_element3 = data6\[/code\]Using the awesome example at Tony Marsden's site I have been able to get the table to extract the data into the form:\[code\]<table> <heading1_sub1_element1>data1</heading1_sub1_element1> <heading1_sub1_element2>data2</heading1_sub1_element2> <heading1_sub1_element3>data3</heading1_sub1_element3> <heading1_sub2_element1>data4</heading1_sub2_element1> <heading1_sub2_element2>data5</heading1_sub2_element2> <heading1_sub2_element3>data6</heading1_sub2_element3></table>\[/code\]However what I would like to get to is:\[code\]<heading1> <sub1> <element1>Data1</element1> <element2>Data2</element2> <element3>Data3</element3> </sub1> <sub2> <element1>Data4</element1> <element2>Data5</element2> <element3>Data6</element3> </sub2></heading1>\[/code\]Does anyone have any idea on how to get the data into that format? will I need to use XSLT, or can PHP do this directly?My only reason for doing this is that the XML looks a whole load better.Thanks in advance, and any assistance will be greatfully recieved.
 
Back
Top