Remove xml declaration after creating 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!

GlennWilson
Posts: 33
Joined: Wed Sep 01, 2010 2:22 pm

Remove xml declaration after creating xml file

Hi,

I am using the "New XML File" feature in AI to create a new xml document. I am then populating this xml file by using a number of public properties. All of this works as expected. However, the xml document contains the xml declaration at the top of the file (<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>), which is causing problems with the installed application. I have tried removing this line using an attached custom action which uses a vbscript to remove the first line of the document. I pass the name of the file (including the path) as the Action Data. A check in the vb script indicates that this is the correct value. I have placed this custom action in the InstallFinalize sequence. For some reason, the script is not updating the file (the script has been tested outside AI and works).

Any idea what I may be doing wrong? Is there another way to remove the xml declaration from the file?

Regards,

Glenn
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Remove xml declaration after creating xml file

Hi Glenn,

Try scheduling the custom action after PublishProduct standard action as deferred with no impersonation. This way it will run under the system account with full privileges.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
GlennWilson
Posts: 33
Joined: Wed Sep 01, 2010 2:22 pm

Re: Remove xml declaration after creating xml file

Hi Cosmin,

Thank you for your reply. I still seem to be having problems with this. When I step through the installation process, I notice that the xml file is created before the script is run. When I run the script, I show the full path in a message box and have confirmed this is the correct path. However, when I run the line

Code: Select all

Set objXmlFile = fso.OpenTextFile(filename, ForReading)
The code fails (fso is already defined and ForReading is a constant representing the value 1). When I include a boolean check for the availability of the file, it returns false.

It's as if the file is created by AI, but the scripting engine isn't aware of the presence of the file.

I have checked my vbscript independently and it appears to be valid. If this method of removing the xml declaration doesn't work, is there an alternative method?

Regards,

Glenn
GlennWilson
Posts: 33
Joined: Wed Sep 01, 2010 2:22 pm

Re: Remove xml declaration after creating xml file

Problem solved!

The CustomActionData property being passed to the script was enclosed in double quotes. These appear to have been added when I added a property within the Action Data field of the Custom Actions Property page. I removed the quotes and the script worked.

I knew it wouild be something simple :roll:

Glenn

Return to “Common Problems”