Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-22-2012, 05:43 PM   PM User | #1
benniii
New to the CF scene

 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
benniii is an unknown quantity at this point
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
benniii is offline   Reply With Quote
Old 03-23-2012, 07:59 AM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,881
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
which language are you allowed to accomplish that?
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 03-23-2012, 12:49 PM   PM User | #3
benniii
New to the CF scene

 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
benniii is an unknown quantity at this point
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.
benniii is offline   Reply With Quote
Old 03-23-2012, 01:57 PM   PM User | #4
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,881
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
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.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 03-23-2012, 02:02 PM   PM User | #5
benniii
New to the CF scene

 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
benniii is an unknown quantity at this point
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.
benniii is offline   Reply With Quote
Old 03-23-2012, 05:01 PM   PM User | #6
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,881
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
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.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Reply

Bookmarks

Tags
convert, structure, transform, xml, xslt

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:46 AM.


Advertisement
Log in to turn off these ads.