-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter42.amp
More file actions
53 lines (45 loc) · 1.51 KB
/
chapter42.amp
File metadata and controls
53 lines (45 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%%[
/* Set the XML source with product data */
Set @productsXml = "<products>
<product>
<name>Smartphone</name>
<description>Latest model with amazing features</description>
<price>299.99</price>
<availability>In Stock</availability>
</product>
<product>
<name>Laptop</name>
<description>Powerful laptop with long battery life</description>
<price>799.99</price>
<availability>Out of Stock</availability>
</product>
<product>
<name>Headphones</name>
<description>Noise-canceling over-ear headphones</description>
<price>149.99</price>
<availability>In Stock</availability>
</product>
</products>"
/* Parse the XML and build a rowset of products */
Set @productRowset = BuildRowsetFromXml(@productsXml, "/product", 1)
/* Loop through each product in the rowset */
Set @rowCount = RowCount(@productRowset)
]%%
<p>Check out these amazing products available in our store:</p>
%%[
For @i = 1 to @rowCount do
Set @product = Row(@productRowset, @i)
Set @name = Field(@product, "name")
Set @description = Field(@product, "description")
Set @price = Field(@product, "price")
Set @availability = Field(@product, "availability")
]%%
<p><strong>Product: %%=v(@name)=%%</strong></p>
<p>Description: %%=v(@description)=%%</p>
<p>Price: $%%=v(@price)=%%</p>
<p>Availability: %%=v(@availability)=%%</p>
<hr>
%%[
Next @i
]%%
<p>Visit our store to order today!</p>