Skip to main content
Solved

Populate a sequence of XML elements with the contents of a list attribute

  • December 3, 2025
  • 2 replies
  • 75 views

steve.carroll
Contributor
Forum|alt.badge.img+1

I am new to lists and xml in FME and having a bit of trouble. I am trying to use the XMLTemplater to populate an XML tag using a list value.

My XML template looks like this:

 

<prompt>{fme:get-attribute("prompt")}</prompt>
            <output>{fme:get-attribute("output")}</output>
            <data>
            {
            for $testcount in fme:get-list-attribute("itemlist{}")
            return <item>{$testcount}</item>
             }
            </data>

 

Test count is the output of a list element counter, and itemlist is a list attribute of the items.

 

My output looks like this:

 

<prompt>Material</prompt>
            <output>Survey Attributes/Material</output>
            <data>
            
            </data>

 

There are no contents being created within the data tag.

I am trying to get it to output like this:

 

<prompt>Material</prompt>
            <output>Survey Attributes/Material</output>
            <data>
            <item>Concrete</item>

            <item>Steel</item>

            <item>Timber</item>
            </data>

 

The help guide gives an example of this:

 

<roads>

{

for $road_id in fme:get-list-attribute("road_ids{}")

return <road id="{$road_id}"/>

}

</roads>

 

I am just a bit confused what attributes get defined to make these list elements populate in the xml.

 

In the example, is $road_id a list element counter attribute, or is this something else?

 

Any help is appreciated.

 

Best answer by ebygomm

<data>

{
for $material in fme:get-list-attribute("itemlist{}")

return <item>{$material}</item>

}
</data>

Something like this should work

 

Although your example works for me too

2 replies

ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • Best Answer
  • December 3, 2025
<data>

{
for $material in fme:get-list-attribute("itemlist{}")

return <item>{$material}</item>

}
</data>

Something like this should work

 

Although your example works for me too


steve.carroll
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • December 3, 2025

Thanks for your help.  I have got it working now.  I ended up needing to add ‘.item’ after the list attribute call.  

Final XML template now looks like this:

 

<data>

{

for $material in fme:get-list-attribute("itemlist{}.item")

return <item>{$material}</item>

}

</data>