If I have an number of tags, all with the same name that are not contained in a repeater, I can iterate over them in a Map by using the tag name, but, how do I then specify the current item being iterated if I want the value of it?
e.g. We have a tag of Item which is used several times on various questions.
In the map we have
{
"Name": "Items",
"ForEach": "Item",
"Setter": "array",
"Attributes": [
{
"Name": "Description",
"Value": "<<Item>>"
}
]
}
The resulting XML from this is
<Items><Description></Description></Items>
How do I get the Description element populated with the contents of the current Item node?
1 Answers
Answer by Anonymous ✅ (Accepted)
We can’t produce XML output like this…
<?xml version="1.0" encoding="utf-8"?>
<Items>
<Description>1</Description>
<Description>2</Description>
<Description>3</Description>
</Items>
The closest we can get would be this…
<?xml version="1.0" encoding="utf-8"?>
<Items>
<Item>
<Description>1</Description>
</Item>
<Item>
<Description>2</Description>
</Item>
<Item>
<Description>3</Description>
</Item>
</Items>
…which you can generate with this map…
{
"Name": "Items",
"Entities": [
{
"Name": "Item",
"ForEach": "Item",
"Setter": "array",
"Attributes": [
{
"Name": "Description",
"Value": "<<[This]>>"
}
]
}
]
}
Comments:
- Sure, I left out some of the parent info in the map, so yes we are wrapping in an outer Entities array. But, you answered the question with the «[This]» value which is what I need. Cheers, — Anon