Skip to main content
Question

how to extract atteibutes from xml ?

  • February 24, 2026
  • 1 reply
  • 8 views

gogopotter90
Contributor
Forum|alt.badge.img+14

a file like the following.
I am reading it using a Text Reader dataset in XML format.
I would like to use XML Fragment / XML Flattener to extract the Name attribute and its value, but I always get no result from the XML Fragment.
I am not sure what the reason is. Could someone please help me?
Thanks in advance.
FME 2021

<processXMLRequest  >

<field >

<name>text1</name>

<value>value1</value>

</field>

<field >

<name>text2</name>

<value>value2</value>

</field>

<field >

<name>text3</name>

<value>value3</value>

</field>

<field >

<name>text4</name>

<value>value4</value>

</field>

<field >

<name>text5</name>

<value>value5</value>

</field>

<field >

<name>text6</name>

<value>value6</value>

</field>

<field >

<name>text7</name>

<value>value7</value>

</field>

<field >

<name>text8</name>

<value>value8</value>

</field>

<field >

<name>text9</name>

<value>value9</value>

</field>

<field >

<name>text10</name>

<value>value10</value>

</field>

<field >

</processXMLRequest>

1 reply

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • February 27, 2026

Hi ​@gogopotter90 

As the attribute name and value is stored in different elements in the XML, simply using the XMLFragmenter and/or the XMLFlattener won’t be enough to extract the information in the format you want.

You’ll want to fragment the XML per field node and flatten using the XMLFragmenter, then dynamically create attributes using the value of the name attribute and set its value to the value attribute with an AttributeCreator. Once you have done this, you can expose the created attributes with an AttributeExposer.

Another method is using XMLXQueryExtractor which requires knowledge of XQuery. The pro of this method is it only requires one XMLXQueryExtractor and an AttributeExposer.

Attached is a workspace that demonstrates both these approaches and I hope it helps.