Creating dynamic xml

The help files give an example like this to convert a sting to xml

var xml:XML =
trace(xml); // hello
trace(xml.toXMLString()); // <p>hello</p>

However I need it to be dynamic and more like this:

var newXml:XML =
for (var i:int=0;i<oldXmlList.length(); i++) {
           <books id=" + oldXmlList*[email protected] + " value=" + sliderValues*.value + " />")

Im obviously doing something wrong. Does anyone knoe the correct methods and syntax I need to use here?