Solved

Get a filename part while mapping XML


Userlevel 1
Badge

Hello,

I need to get a specific filename part value while mapping XML to the desired structure in the XMLMap connector. F. ex. I need to extract ‘1234’ part from a file name 1234_abcd.xml.

I have tried to write an expression in the Expression Editor: [getfilename(substring(0, indexof(filename(), "_")))]

It does not work and I am not sure that is wrong.

Any ideas? Maybe there are even better solutions?

icon

Best answer by Charlie S 2 May 2023, 17:25

View original

2 replies

Userlevel 3
Badge

If you are looking to get the 1234 portion of that filename, you can use the split formatter (https://cdn.cdata.com/help/AZH/mft/String-Formatters.html#splitdelimiter-indextoreturn) to split on the underscore character in the filename and return the first substring that resulted from the split.

Like this:

[filename | split(‘_’1)]

This expression would resolve to the value of “1234”.

Does this work for you?

Userlevel 1
Badge

Yes, thank you for your help!

Reply