Monday, 20 October 2014

How to use populate placeholders in XML template using Scala XML?



I have the following XML template and using Scala XML I'd like to have those placeholders properly populated but I can't find the API for this. Can anyone advice whether this is possible at all?



<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures={failures} time={time} errors={errors} skipped="0" tests={tests} name="k4unit">
<properties />
</testsuite>


The Scala code so far:



scala> import scala.xml.XML
import scala.xml.XML

scala> val xml = XML.loadFile("./testcases/TEST-k4unit-template.xml")
xml: scala.xml.Elem =
<testsuite name="k4unit" tests={tests} skipped="0" errors={errors} time={time} failures={failures}>
<properties/>
</testsuite>


I'd like to have the attributes tests, errors, time and failures populated with dynamic values.


No comments:

Post a Comment