Skip to main content
Solved

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

  • December 3, 2025
  • 2 replies
  • 99 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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

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>