Need to parse a text file into a specific xml format

allkahovbdua

New Member
Need to parse a text file into a specific xml format.(file is a huge one millions of line and looks like this)ABC-DATA-FILE-VERSION: 2.0OBJFILE: /home/abc/src/solaris/abc.oTIMESTAMP: 1348314377 727216SRCFILE: /home/abc/src/solaris/abc.C\[code\] 167 7 170 7 174 0 179 0 174 0 192 7 196 7 199 7 215 0\[/code\]OBJFILE: /home/abcd/src/solaris/abcd.oTIMESTAMP: 1348314377 727216SRCFILE: /home/abcd/src/solaris/abcd.C\[code\] 58 7 65 7 66 7 67 7 69 0 79 0 84 0 97 14 100 7 108 14 110 7 115 14\[/code\]OBJFILE: /home/abcd/src/solaris/xyz.oTIMESTAMP: 1348314377 727216SRCFILE: /home/abcd/src/solaris/xyz.C\[code\] 978 0 979 1 993 0 996 0 997 0 1011 0 1003 0 1004 0 1011 0\[/code\]Now i wanted to convert it to a specific xml file format. like\[code\]<packages> <package name="com" line-rate="0.45161290322580644" branch-rate="0.4915254237288136" complexity="3.391891891891892"> <classes> <class branch-rate="0" complexity="0" filename="/home/abcd/src/solaris/abcd.C" line-rate="0.25" name="TestRunnerModel"><methods/><lines><line number="13" hits="1" branch="true"/><line number="14" hits="1" branch="true"/><line number="15" hits="1" branch="false"/><line number="12" hits="0" branch="false"/></lines></class> <class branch-rate="0" complexity="0" filename="/home/abcd/src/solaris/abcd.C" line-rate="0.25" name="TestRunnerModel"><methods/><lines><line number="13" hits="1" branch="true"/><line number="14" hits="1" branch="true"/><line number="15" hits="1" branch="false"/><line number="12" hits="0" branch="false"/></lines></class> <class branch-rate="0" complexity="0" filename="/home/abcd/src/solaris/xyz.C" line-rate="0.25" name="TestRunnerModel"><methods/><lines><line number="13" hits="1" branch="true"/><line number="14" hits="0" branch="true"/><line number="15" hits="1" branch="false"/><line number="12" hits="0" branch="false"/></lines></class> </classes> </package></packages>\[/code\]Most of the xml parameters are constant only few i need to populate likeFILENAME readinng from SRCFILE: /home/abcd/src/solaris/xyz.Candline number="978" hits="0" branch="true"line number="979" hits="1" branch="false"etcand so on. Please help.
 
Back
Top