I've been wracking my brain trying to solve this problem. This is my first time using any scripting language for this kind of work, and I guess I might've picked a hard job to start with. Essentially, what I need to do is transform some basic XML into a heavier XML structure.
Example :
Translate the following :
<xml>
<test this="stuff">13141</test>
<another xml="tag">do more stuff</another>
<xml>
Into this :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Package>
<Package version="1.0">
<tests>
<test name="stuff">
<information>13141</information>
</test>
</tests>
<anothers>
<another name="tag">
<information>do more stuff</information>
</another>
</anothers>
</Package>
I've tried doing it manually via regex, but that is a lot of work to do. I've tried storing, for example, multiple test tags into an array, so I can save them into the tests tag in the second example, but I can't seem to keep track of everything. I've looked into REXML and Hpricot, but can't figure out how to use them to properly do this.
So, basically, what I'm asking is : Does anyone have any ideas on how I might be able to manage this in a more efficient way?