CarlsbergFTW
asked on
reformating XML , need to add nodes depending on one attribute id.
hello, i need to generate an xml file using data from a mysql database.
Aftger concatenating the tables + tags inside the select query i managed to create this kind of format:
What i need is a script or a way using mysql or some linux tool that can be automated (.pl .sh .whatever) to insert nodes depending on the id value found in the xml output i posted.
final output should be like this:
Thank you experts!
Aftger concatenating the tables + tags inside the select query i managed to create this kind of format:
<BEGIN>
<client id="A1" title="A1 random status" some_attribute="2011-05-03 05:20:04" no="32"/>
<client id="A1" title="A1 random x status" some_attribute="2011-05-03 18:00:03" no="32"/>
<client id="A1" title="A1 r2 status" some_attribute="2011-05-03 05:30:01" no="32"/>
<client id="A1" title="A1 random status" some_attribute="2011-05-03 19:00:02" no="32"/>
<client id="B1" title="B1 000 status" some_attribute="2011-05-03 01:20:02" no="32"/>
<client id="B1" title="B1 bla bla status" some_attribute="2011-05-03 13:20:03" no="32"/>
<client id="C2" title="C2 xx status" some_attribute="2011-05-03 05:20:06" no="32"/>
<client id="C2" title="C2 xoxoxo status" some_attribute="2011-05-0305:20:06" no="32"/>
</BEGIN>
What i need is a script or a way using mysql or some linux tool that can be automated (.pl .sh .whatever) to insert nodes depending on the id value found in the xml output i posted.
final output should be like this:
<BEGIN>
<A1>
<client id="A1" title="A1 random status" some_attribute="2011-05-03 05:20:04" no="32"/>
<client id="A1" title="A1 random x status" some_attribute="2011-05-03 18:00:03" no="32"/>
<client id="A1" title="A1 r2 status" some_attribute="2011-05-03 05:30:01" no="32"/>
<client id="A1" title="A1 random status" some_attribute="2011-05-03 19:00:02" no="32"/>\
</A1>
<B1>
<client id="B1" title="B1 000 status" some_attribute="2011-05-03 01:20:02" no="32"/>
<client id="B1" title="B1 bla bla status" some_attribute="2011-05-03 13:20:03" no="32"/>
</B1>
<C1>
<client id="C2" title="C2 xx status" some_attribute="2011-05-03 05:20:06" no="32"/>
<client id="C2" title="C2 xoxoxo status" some_attribute="2011-05-0305:20:06" no="32"/>
</C1>
</BEGIN>
Thank you experts!
This should be doable by awk.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the result is like:
<BEGIN>
<A1>
<client id="A1" title="A1 random status" some_attribute="2011-05-03 05:20:04" no="32"/>
<client id="A1" title="A1 random x status" some_attribute="2011-05-03 18:00:03" no="32"/>
<client id="A1" title="A1 r2 status" some_attribute="2011-05-03 05:30:01" no="32"/>
<client id="A1" title="A1 random status" some_attribute="2011-05-03 19:00:02" no="32"/>
</A1>
<B1>
<client id="B1" title="B1 000 status" some_attribute="2011-05-03 01:20:02" no="32"/>
<client id="B1" title="B1 bla bla status" some_attribute="2011-05-03 13:20:03" no="32"/>
</B1>
<C2>
<client id="C2" title="C2 xx status" some_attribute="2011-05-03 05:20:06" no="32"/>
<client id="C2" title="C2 xoxoxo status" some_attribute="2011-05-03 05:20:06" no="32"/>
</C2>
</BEGIN>
<BEGIN>
<A1>
<client id="A1" title="A1 random status" some_attribute="2011-05-03
<client id="A1" title="A1 random x status" some_attribute="2011-05-03
<client id="A1" title="A1 r2 status" some_attribute="2011-05-03
<client id="A1" title="A1 random status" some_attribute="2011-05-03
</A1>
<B1>
<client id="B1" title="B1 000 status" some_attribute="2011-05-03
<client id="B1" title="B1 bla bla status" some_attribute="2011-05-03
</B1>
<C2>
<client id="C2" title="C2 xx status" some_attribute="2011-05-03
<client id="C2" title="C2 xoxoxo status" some_attribute="2011-05-03
</C2>
</BEGIN>
ASKER
Thank you for this imput. i will let you know about the result!
ASKER
Thank you!
ASKER
Thank you!