i made a script using tcldom:
package require utils
package require testrunscheduler
package require tdom
tla::TSConfig::init -schedulerContext "Reporting" -environment production
tla::TSDBFactory::getConnection db
set testCaseList [$db doSQL "SELECT root_name,suite_name,case_name FROM ics where test_type = 'tce' limit 1"]
set item [join $testCaseList ""]
set doc [dom createDocument testCases]
set root [$doc documentElement]
set subnode [$doc createElement testCase]
$root appendChild $subnode
foreach item $item {
set node [$doc createElement root]
$node appendChild [$doc createTextNode $item]
$subnode appendChild $node
}
Output i get is :
<testCases>
<testCase>
<root>SPB</root>
<root>subscriberServices</root>
<root>jmsServices</root>
</testCase>
</testCases>
but i want output to be like :
<testCases>
<testCase>
<root>SPB</root>
<suite>subscriberServices</suite>
<case>jmsServices</case>
</testCase>
</testCases>
i used foreach for this, but it makes only for root, i am missing probably, this structure would iterate itself and grow as on the users input from sql query.
<testCases>
<testCase>
<root>demoRoot</root>
<suite>demoSuite</suite>
<case>demoCase</case>
<testCase>test_demo001</testCase>
</testCase>
<testCase>
<root>demoRoot</root>
<suite>demoSuite</suite>
<case>demoCase</case>
<testCase>test_demo002</testCase>
</testCase>
</testCases>
Please help me to get this kind of output, its very tedious to get this putput which is repetative but with one structure.