View Full Version : Reading XML in an installation.

02-15-2006, 10:51 AM
The facts: installation A installs some base files such as DLLs, etc. installation B installs some executables and these are started as Windows services. No problem, all works well.

Installation A installs some configuration files which are all app.config files as you create them in a .Net project. What I need to do now is read one of those configuration files and get all the elements called Port1, Port2, Port3, etc (there can be as many of them as needed).

For example, the configuration file might have these:

<add key="Port1" value="25000"/>
<add key="Port2" value="25001"/>

So, when I install B, it needs to read these elements and it would then create two services, say ServiceB1 and ServiceB2. They would each receive the value in the element as the service startup parameter. The problem I have and which has scared me since version 10 is that I found that using XML in an installation is fraught with extreme peril and was intensely unreliable. I only need to read the XML.

What's the best way to read this XML and what's the best to create the services at installation time? At the moment I create the services statically and I have them in the project but I now need to control their creation using what's in the XML file. Maybe I need to put a cap on the number and create say 50 of them in the installation but hook them up to conditions using properties whose values come from the XML file. Something on the lines of, Not Installed And INSTALLSERVICE1 etc, etc.

Any ideas? I have a service call for this but maybe someone can give me a head start?


03-22-2006, 06:23 PM
Have you had any luck accomplishing this? I need to do something similar

03-23-2006, 11:11 AM
What methods have you used to read the XML? Have you tried using Window's XML objects in VBScript or JavaScript to parse your file? Since you only need to read the file, would using FileGrep to get the line you're looking for work for you?

03-24-2006, 09:15 AM
Actually I needed to modify the file based on user input. I turned to vbscript and have got it working. Thanks for the response.

03-26-2006, 05:05 AM
I did it getting working using an XML XPath system search.