ckovamees
Posts: 18
Joined: Fri Aug 05, 2011 3:16 pm

Updating XML-file when "preventing file being overwritten"?

Hi again,

I have read and inplmented the "How do I prevent a file from being replaced by a newer version?" as desribed in http://www.advancedinstaller.com/user-g ... le-ca.html.

I was just wondering if there is a best practice etc for the case that the file also need to be updated (e.g. added some elements etc)?


Thanks,


/Carl
Bogdan
Posts: 2794
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Updating XML-file when "preventing file being overwritte

Hi Carl,

For preserving some element and updating others from the file, XML I suppose, you can use another approach.

The one you have already found in our user-guide presents the correct method of preserving the file entirely, but if you want to updater certain elements from it
I recommend the following:
-- in your new version include an XML search, as described in our tutorial
-- the search will be used to obtain the entire content of the XML file, you can use it to store its contents in propertier very easy, as you can see in the tutorial
-- then in Files and Folders page use the properties set by the search as elements in the new XML file, i.e. for the elements you want to keep
-- for the elements you want to update simply use new properties, which are not set by the XML search that you will make.

So, when your new version package is launched the search will run in the beginning, retrieve the XML content and placing it into new properties, based on your settings,
the old XML is completely removed and the new one will be created using the search results as well as the new values which you wish to be updated.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ckovamees
Posts: 18
Joined: Fri Aug 05, 2011 3:16 pm

Re: Updating XML-file when "preventing file being overwritte

Thanks for your help - it's good to get some input on these things.

My scenario is a little different (aren't they all ;-). I want to keep the old config file (which is fairly large), I don't want to recreate it every time since I would need to parse and insert many values (and I might forget one). Keeping the old file seems easier (read less work for me).

However, sometime in the future I might need to add elements or modify a current element/attribute in the old file. Is there any easy way to updated the XML-file after the restore operation?

I'm just bouncing ideas here - any pointer is appreciated.
ckovamees
Posts: 18
Joined: Fri Aug 05, 2011 3:16 pm

Re: Updating XML-file when "preventing file being overwritte

Also, I just tried the XML search but it seems like the XML file (installed by the previous version) isn't found during search - so my properties doesn't show up.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Updating XML-file when "preventing file being overwritte

Hello,

Have you tried implementing the scenario Bogdan described? You could try it on a test project first to ensure it works.

If you have any queries or doubts about the steps, please don't hesitate to ask.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ckovamees
Posts: 18
Joined: Fri Aug 05, 2011 3:16 pm

Re: Updating XML-file when "preventing file being overwritte

I started, but there are hundred of elements/attributes and I don't think it's very maintainable... There must be a better way.

What I want is a 'XML Updater' of the restored file. I just want to add another element, or change an existing one. To have to have hundreds of variables for this seems a little excessive ;-)
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Updating XML-file when "preventing file being overwritte

Hello,

Another way you could try is to use XML Updates and to modify the functionality of this article so that it restores the files before the XML Updates are installed.

You can try to schedule the restore custom actions somewhere before the WriteINIValues standard action instead of Install.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”