transform XML to XML - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

transform XML to XML

I have XML that I need to tranform to another structure of XML. The XML I need to transform is below:



1
text


text#1
text#1


text#2
text#2


text


2
text2


text#3
text#3

text




This needs be tranformed to:







Text#1
Text#1









Text#2
Text#2









Text#3
Text#3






Wherever exists, it needs to loop over each and insert each individual into the rest of the data for that group. So if there are 3 's, it should repeat the entire group and insert one of the nodes.

Thanks in advance

Comments

  • jeet1212jeet1212 Posts: 4Member
    Hi,

    Please try below code...I think it will help you.

    <?xml version="1.0" encoding="UTF-8"?>






















    Thanks!
  • sgoldbergsgoldberg Posts: 2Member
    Thank you! That was perfect. I was trying to use "copy-of" and manipulate the for each after the copy was done. This is great xslt!
  • mdabirimdabiri Posts: 1Member
    I also need to transform xml to xml but the result xml does not show as xml, I can only see the transformed values i,e in this example, I see Text#1 Text#1 on one line and Text#2 Text#2 on the second and not an xml file and when I view source, I only see the original xml doc.
    Maybe not using the correct tranformation instruction. Your help is much appreciated..

    This is the xml file
    ----------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="arrayNode.xslt"?>






    Text#1
    Text#1









    Text#2
    Text#2





    ------------------------------------
    And here is the xsl file called arraynode.xslt

    <?xml version="1.0" encoding="UTF-8"?>





















    -------------------------------
    And here is the result of transformation.
    Text#1 Text#1
    Text#2 Text#2
    But I want another xml file..

Sign In or Register to comment.