Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    convert xml structure to another

    hei there, i'm slowly going maaad!
    i'm pretty new to xml and i need to convert one structure into a (for me seemingly totally) different one. here's an excerpt of what i'm trying to do:

    old xml structure:

    Code:
     <row>
            <forum>forum 1</forum>
            <title>topic 1</title>
            <date>2009-09-22 15:22:24</date>
            <poster>benniii</poster>
            <content>content test 1</content>
        </row>
     <row>
            <forum>forum 1</forum>
            <title>topic 1</title>
            <date>2009-09-23 16:11:22</date>
            <poster>thomas</poster>
            <content>content test 2</content>
        </row>
        <row>
            <forum>forum 2</forum>
            <title>topic 1</title>
            <date>2009-09-06 14:36:21</date>
            <poster>benniii</poster>
            <content>content test 3</content>
        </row>

    xml structure i'm desperately trying to achieve

    Code:
       <topic forum="forum 1" title="topic 1">
          <message posted="2009-09-22 15:22:24" by="benniii">content test 1</message>
          <message posted="2009-09-23 16:11:22" by="thomas">content test 2</message>
       </topic>
      <topic forum="forum 2" title="topic 1">
          <message posted="2009-09-06 14:36:21" by="benniii">content test 3</message>
       </topic>

    i'd be dyingly gracious for any clue how to get this to work.

    if the above is totally misunderstanding, here's a screenshot of the structure i need:

    thanks so much,
    benni

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,436
    Thanks
    13
    Thanked 360 Times in 356 Posts
    which language are you allowed to accomplish that?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm sorry i'm really a newbie to this.. what do you mean with 'which language'?
    basically, i just need the first part of code's structure to look like the second. i've heard some stuff about xslt and that it might be able to convert it as needed, but i have no clue

    thanks for your reply, so far.

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,436
    Thanks
    13
    Thanked 360 Times in 356 Posts
    yes, XSLT is able to do that conversion, but it's not the only one. pretty much every programming language (e.g. C++, Java, PHP, C#, ...) that is able to read XML can do that conversion as well.

    and tbh, I'd rather use a programming language than XSLT.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok .. but .. i have no idea how to do so ..

    isn't there any way to do this "simply" or online or somewhat?
    some scheme you input as an algorythm or something, to then convert the old structure into the new one?

    it's basically just this very one set of data in the above structure i need to restructure.

    i'm sorry for my incapability.

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,436
    Thanks
    13
    Thanked 360 Times in 356 Posts
    Quote Originally Posted by benniii View Post
    isn't there any way to do this "simply" or online or somewhat?
    nope, there isn’t (excluding conversion by hand, which is the most simple, the longest taking (unless you only need to do that once) and most error prone method)


    Quote Originally Posted by benniii View Post
    some scheme you input as an algorythm or something, to then convert the old structure into the new one?
    that’s commonly known as a programme (and yes, for the sake of this task I consider XSLT as a programming language).


    Quote Originally Posted by benniii View Post
    it's basically just this very one set of data in the above structure i need to restructure.
    if it’s just that (i.e. a one-time action), you could do it manually.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •