I am producing an XML file in a loop. I write one feature formatted as XML at a time. In the next loop execution I wish to write over what is in the file or wipe it out completely and write the current feature. Thanks.
Writing over a feature in an XML file or how to write over an existing feature in a loop?
Hi @mkumbale,
I think in order to best assist in this workflow, we need a greater understanding of the logic behind the workflow. What are you trying to accomplish, how will this workflow be implemented; these are the types of questions that will help us understand the nature of your problem.
I could give you some suggestions - for example using a Decelerator to ensure each writer feature is picked up before the XML is re-written, however, this may not be the most beneficial workflow if this is to be uploaded to Server.
If you are able to share with us the logic behind this workspace(for example what is the purpose of needing the XML to only have 1 feature) - will something be consuming this output XML?
I am trying to generate non-spatial data feed to a program in XML format. This data feed is refreshed with new data say once ever 2 minutes. I have created a loop to update the XML data feed (and later plan to add a WorkspacePauser that would pause for 2 minutes, so that way the next loop would be executed after 2 minutes). I generate new XML output with each loop execution. I want the data I have generated in the current loop to completely write over the old data. I have enclosed the FME workspace.
Hi @mkumbale, the Text File writer will append entered features to the destination file one by one while the workspace is running, and closes the file finally when the translation completed. It won't overwrite the file while a single translation process.
It would be ideal if you could use an FME Server to schedule a job to run a workspace overwriting XML.
However, as the second best, I think the AttributeFileWriter transformer could be used effectively in your case, if the workspace should be run with FME Desktop. By default, the AttributeFileWriter overwrites the destination file whenever it receives a feature.
Besides, I don't think you need to do that with looping. You can just create (or copy) multiple (e.g. 4) features, control time interval between continuous features with the Decelerator transformer, create an XML document, and then update the file with the AttributeFileWriter.
Hi @mkumbale, the Text File writer will append entered features to the destination file one by one while the workspace is running, and closes the file finally when the translation completed. It won't overwrite the file while a single translation process.
It would be ideal if you could use an FME Server to schedule a job to run a workspace overwriting XML.
However, as the second best, I think the AttributeFileWriter transformer could be used effectively in your case, if the workspace should be run with FME Desktop. By default, the AttributeFileWriter overwrites the destination file whenever it receives a feature.
Besides, I don't think you need to do that with looping. You can just create (or copy) multiple (e.g. 4) features, control time interval between continuous features with the Decelerator transformer, create an XML document, and then update the file with the AttributeFileWriter.
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.