Skip to main content

Good morning.

I have the XML file of an ATOM feed. That XML has to be updated every time the resources provided by that service are updated. Several dates must be changed.

My first approach is read the XML with the XML reader, calculate the current data, modify the XML using the XMLTemplater and wirting the same XML file using the Text File reader (with "Overwrite" set to YES)..

The process reads the C:/ATOM_feed.xml, edits it and writes the file C:/ATOM_feed.xml.

This doesn't work:

"Error opening dataset 'Text File' for writing, ensure that file path and permissions allow for writing".

I guess it makes sense.

So, in order to avoid this, I have used "Creator" to create a feature with an attribute "join" set to "A". I have added the same attribute to the feed from the XML Reader and I have perfomed a Merge using "FeatureMerger" (Requestor = new feature, Supplier = XML). That way I can read and write the same XML file. The merge is the input of the XML Templater.

But I keep looking at my FME project thinking if there is a "prettier" solution. I tend to miss the simple solution, so... Is there a more elegant way to read and write the same XML file?

Thanks for any help provided!

I'm using FME Desktop 2016.

I suspect your solution is pretty optimal, simultaneously reading and writing the same file on disk is asking for trouble, so the OS tries its best to discourage you with a built-in mechanism called file locking.

If you want to learn more about file locking, this is a pretty good starting point: https://en.wikipedia.org/wiki/File_locking


Hi @oscard, if the update can be done with an XQuery expression, you can use the XMLXQueryUpdater transformer to update the XML file directly.

Alternatively, just inserting a FeatureHolder before writing might be effective to avoid the problem.


Reply