Skip to main content

Hi all,

 

I am using FME desktop to publish XMLs out. I'm currently using the XML templater and need to edit one of the attributes that is coming through via a feature reader.

 

The sub template expression looks like this (redacted some lines due to data):

<data>

<dataid>{fme:get-attribute("dataid")}</dataid>

</data>

 

There's several other attributes in the XML but I'm not interested in those.

 

Basically what I would like to do is trim the value in that attribute as the attribute has the current format ABCD*00000000001. I only require the numbers in the attribute and only want these written to the final XML output.

 

How do I go about making changes to the XML attributes. I have tried looking at XQueries but not got very far.

 

Many thanks

Hello @opannell01​ 

XQuery would be an option if you want to only use XMLTemplater. You should be able to use the XQuery function fn:replace to replace the letters and asterisk symbol in the attribute value with an empty string. For example:

<dataid>{fn:replace({fme:get-attribute("dataid")}, "nA-Za-z]+\*","")}</dataid>

Alternatively, you can also use a StringReplacer transformer with the same regex to get same results for the dataid attribute before the XMLTemplater.


Reply