XML : text to xml conversion using php script

What i am trying to achieve . I have a bunch of data that i want to convert to xml file in a specific format so i can upload it to my website. I have tried using simple conversion technique but it is not giving an expected output

What i am trying to convert

eg

Parent1,Parent2,-child1,-child2,-child3,.,.,. ParentA,ParentB,-childA,-childB,-childC,.,.,. more such

I want to convert the above type data in the following format

      <title>parent1</title>      <subtitle>parent2</subtitle>      <type>      <atype>child1</atype>      <btype>child2</btype>      <ctype>child3</ctype>      </type>    

Now some parts of original text has 3child and some has 4child so how do it make it to work in auto conversion format based on available text

   <title><?php echo $_POST['parent1']; ?></title>   <subtitle><?php echo $_POST['parent2']; ?></subtitle>   <type>   <atype><?php echo $_POST['child1']; ?></atype>   <btype><?php echo $_POST['child2']; ?></btype>   <ctype><?php echo $_POST['child3']; ?></ctype>   </custom>    

I used to convert text based on above code but how do i make it to auto adjust for more input variables.

No comments:

Post a Comment