I have a field that is receiving a list of values formatted in XML. I have a loop, however, the loop is only displaying one set of products. Below is the code I am using.
<?xml version="1.0" encoding="utf-16"?>
<ArrayOfProducts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Products>
<Name>PHONE PROTECTION PLAN</Name>
<ImageUrl>All_Phone_Protection_Plan-small.png</ImageUrl>
<Price>5.99</Price>
<Quantity>1</Quantity>
</Products>
</ArrayOfProducts><?xml version="1.0" encoding="utf-16"?>
<ArrayOfProducts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Products>
<Name>TABLET PROTECTION PLAN</Name>
<ImageUrl>All_Tablet_Small.png</ImageUrl>
<Price>5.99</Price>
<Quantity>1</Quantity>
</Products>
</ArrayOfProducts>
This is the AMPscript.
%%[
Set @ProductInfoXML = Product_Info
Set @rowsetArrayOfProducts = BuildRowsetFromXML(@ProductInfoXML, '//ArrayOfProducts', 1)
Set @rowsetProductName = BuildRowsetFromXML(@ProductInfoXML, '//Name', 1)
Set @rowsetProductImage = BuildRowsetFromXML(@ProductInfoXML, '//ImageUrl', 1)
Set @rowsetProductQuantity = BuildRowsetFromXML(@ProductInfoXML, '//Quantity', 1)
Set @rowsetProductPrice = BuildRowsetFromXML(@ProductInfoXML, '//Price', 1)
for @i = 1 to Rowcount(@rowsetArrayOfProducts) do
if (Rowcount(@rowsetProductName) >= @i) then
Set @Product_Name = Field(Row(@rowsetProductName,@i),1)
else
set @Product_Name = ''
endif
if (Rowcount(@rowsetProductImage) >= @i) then
Set @Product_Image = Field(Row(@rowsetProductImage,@i),1)
else
set @Product_Image = ''
endif
if (Rowcount(@rowsetProductQuantity) >= @i) then
Set @Product_Quantity = Field(Row(@rowsetProductQuantity,@i),1)
else
set @Product_Quantity = ''
endif
if (Rowcount(@rowsetProductPrice) >= @i) then
Set @Product_Price = Field(Row(@rowsetProductPrice,@i),1)
else
set @Product_Price = @rowsetProductPrice
endif
]%%
Product Name: %%=ProperCase(@Product_Name)=%%
Price: $%%=v(@Product_Price)=%%
Quantity: %%=v(@Product_Quantity)=%%
%%[next @i]%%
Thanks, Gaudy