profquail
Posts: 10
Joined: Fri May 20, 2011 8:57 pm

Insert XML element as sibling before/after existing element

When using the XML file feature of Advanced Installer, we're only given the option to insert a new node/element as a sibling to an existing element -- in which case, our new element is always inserted *after* the existing element.

In some cases though, the element I'm inserting needs to come before the existing element (found via a search), and it doesn't seem that there's a way to do that. (Specifically, I'm using the XML feature to create/modify some MSBuild project files, where the order of elements is quite important.)
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Insert XML element as sibling before/after existing elem

Hi,

Please note that XML element order is not guaranteed. I don't think there are any setup authoring tools which do this. XML entries are written in the order they are read from MSI. Only their relations are used (parent, child or sibling).

Also, the application which reads the XML should never rely on a specific element order. It should process the elements in whatever order they are read.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
profquail
Posts: 10
Joined: Fri May 20, 2011 8:57 pm

Re: Insert XML element as sibling before/after existing elem

cosmin wrote:Also, the application which reads the XML should never rely on a specific element order. It should process the elements in whatever order they are read.
I agree. However, MSBuild (prior to the latest version, shipped with .NET 4.0 / Visual Studio 2010) processes project files linearly -- in our case, I need to make sure that our project gets imported before another project by ensuring that the XML element I'm inserting (using the XML file features of Advanced Installer) is inserted as a sibling which comes before the element importing the other project. If it comes after, our project will be imported after, and thus not work correctly.

The MSBuild project schema changed in .NET 4.0 / VS2010, but as we also need to support earlier versions, I'm stuck solving this problem one way or the other. If it's not something that can (or will) be added to Advanced Installer, then the only other solution I can think of is to write a custom action to modify to modify the XML in the file.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Insert XML element as sibling before/after existing elem

Hi,

I checked with our developers and you should be able to control the order by moving elements up or down. Just right-click an element and select "Move Up" or "Move Down" option. However, when updating an existing XML this order is not guaranteed. It depends on your element settings regarding update.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”