Question: I am currently building a website as part of my course. The website is an eCommerce site. I am storing the products in an SQL database, then echoing each row out into a table using a php script. I have managed to do this fine, however, I now wish to add a button on each product that will contain a href which adds that chosen product to a cart. The only problem is, to build the cart array I need the ID, and to set the ID in the loop you have to concatenate an integer, and I do not know how to do this in my script, here is what I currently have, any help would be much appreciated.

```
    while ($row = mysqli_fetch_assoc($result)){
echo "<tr>";
echo "<td><br>".$row['Name']."</td><br>";
echo "<br>";
echo "<td><img src=".$row['Image']."height='200' width = '200'"."</td><br>";
echo "<br>";
echo "<td>Price: £".$row['Price']."</td><br>";
echo "<button type='button'><a href='test.php' id=>Buy</a></button>";
echo "</tr>";

```

}

Thanks in advance, I hope I have given enough detail.

Answer: 
This is tricky because you want to convert all the objects to xml, and might be dealing with large objects that you do not want to explicitly add to the dataweave. To get around this I did the following;

```
%dw 2.0
%input payload application/json
%output application/xml skipNullOn="everywhere"
---
{
    abc: {
        (payload.abc - payload.abc.ggg),
        (payload.abc.ggg map ggg: $)
    }
}

```

I actually tell it to map all properties in the object, and exclude array items. The I tell it to take the array item and use the "map" function to output all the elements. It might not be in perfect order, but it cuts down the dataweave to minimal lines.

The output for this dataweave is;

```
<?xml version='1.0' encoding='windows-1252'?>
<abc>
  <ccc>ddd</ccc>
  <eee>fff</eee>
  <ggg>
    <aaa>a</aaa>
    <bbb>b</bbb>
  </ggg>
</abc>

```
The XML for element `"ggg"` is expecting an `object`, not an `array`. Removing the square brackets `[]` from `[{"aaa":"a","bbb":"b"}]` should solve the issue and the resulting XML should look like the following:

```
<abc>
  <ccc>ddd</ccc>
  <eee>fff</eee>
  <ggg>
    <aaa>a</aaa>
    <bbb>b</bbb>
  </ggg>
</abc>

```