My bad, what I mean is, first I tried it in JavaScript (never mind about this). Since I use session in php thus I will loop my array and put it in DOM. I should try this before asking, below are example I have to create DOM in php. I will change the element name as html table later. What concern me this will also return string or xml format? to xhr.responseText, in the end I have to display this using innerHTML to tag id I have in my html page. Will that still work in IE?
ECHO (toXml($myCart));
function toXml($aCart)
{
$doc = new DomDocument('1.0');
$cart = $doc->createElement('cart');
$cart = $doc->appendChild($cart);
foreach ($aCart as $Item => $ItemName)
{
$book = $doc->createElement('book');
$book = $cart->appendChild($book);
$title = $doc->createElement('title');
$title = $book->appendChild($title);
$value = $doc->createTextNode($Item);
$value = $title->appendChild($value);
$quantity = $doc->createElement('quantity');
$quantity = $book->appendChild($quantity);
$value2 = $doc->createTextNode($ItemName);
$value2 = $quantity->appendChild($value2);
}
$strXml = $doc->saveXML(); // this serializes the XML as a string
return $strXml;
}
This is my previous post of php code that return string with element tr and td (which doesnt work in IE of course):
function toHTML($aModel,$aMaker,$aPrice,$aQty)
{
$tableString="<tr>
<th>Manufacturer</th>
<th>Model</th>
<th>Price</th>
<th>Qty</th>
<th>Total Price</th>
</tr>";
foreach ($aModel as $item)
{
$tableString .="<tr id='".$aModel[$item]."'>
<td>".$aMaker[$item]."</td>
<td>".$aModel[$item]."</td>
<td>".$aPrice[$item]."</td>
<td>".$aQty[$item]."</td>
<td>".$aPrice[$item]*$aQty[$item]."</td>
<td><a href='#' onclick='RemoveItem(\"Remove\",\"".$aModel[$item]."\")';>Remove Item</a></td>
</tr>";
}
return $tableString;
}