Reading from existing XML file - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

kettch
Posts: 28
Joined: Wed Dec 03, 2008 9:34 pm

Reading from existing XML file

Is it possible to read values from an XML file that already exists on the filesystem during installation?

My scenario is that we install an ASP.Net web application that has some appSettings in the web.config. Each time it installs/upgrades we capture values from the user for settings such as database ip, credentials, et cetera. What we would like to do is read the values that are already in the existing web.config and use those values in the installer dialogs so that the user doesn't have to type them all in each time but can still verify the correct values. Is that possible from AI? We've been digging through the documentation and interface to see if we could find something like it but have not been successful.
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Reading from existing XML file

Hi,

Of course you can, here is a tutorial that explains how to get the values into public properties.

Also, you should take into consideration to skip the MSI dialog that prompts the user to input these values during an upgrade, and of course if the values are correctly retrieved from the old file.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kettch
Posts: 28
Joined: Wed Dec 03, 2008 9:34 pm

Re: Reading from existing XML file

So easy...can't believe we missed that in the documentation. :oops:

Thanks!
kettch
Posts: 28
Joined: Wed Dec 03, 2008 9:34 pm

Re: Reading from existing XML file

Okay, another (probably) stupid question. web.config appSetting elements are formatted as follows:

<add key="1" value="true1"/>
<add key="2" value="true2"/>
<add key="3" value="true3"/>
<add key="4" value="true4"/>

How would we go about pulling the value from attribute "value" based on the value of the attribute "key"? One locator is easy enough but it doesn't help us retrieve the value that we want. We tried multiple locators on the same element and that didn't seem to work either.
kettch
Posts: 28
Joined: Wed Dec 03, 2008 9:34 pm

Re: Reading from existing XML file

Also, the values aren't showing up in the dialogs so even if I tell it to pull the attribute value for an attribute name of "key" it doesn't display "1" in the textbox assigned to the property.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Reading from existing XML file

Hello,

Here's a similar post with a sample project to help you with this.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kettch
Posts: 28
Joined: Wed Dec 03, 2008 9:34 pm

Re: Reading from existing XML file

Ah, thank you. Now it works perfectly. :mrgreen:

Return to “Common Problems”