jokr
Posts: 3
Joined: Wed Jun 25, 2014 1:51 pm

Check if XML element has any children

Wed Jun 25, 2014 2:58 pm

Hello,

I would like to be able to check if a certain element exists in a XML file and if it has any children. I thought that with "Element has index" I would be able to check if the element had any children but this is not working since "Element has index" checks the position of the element it belongs to and not if it has a child at that position.
In 11.2 Element has index did actualy work for my purpose, (or at least it seemed to) but as of 11.3 it most definitely does not work.

So here is the question, is there already a way to check if an element exists and if it has children?
I could work around the limitation by adding an attribute to <ApplicationSettings> but this seems redundant as the elements only purpose is to contain a tree for consumption by another program.

Below is an example XML to show what I mean.

Code: Select all

<?xml version="1.0"?>
<Configuration>
  <!-- parameters used during install go here -->
  <InstallParameter id="HelperArguments">--lpc</InstallParameter>
  <!--if specified overrides actions to be done by the installer helper-->

  <InstallParameter id="ConfigFolder">C:\Program Files (x86)\somefolder</InstallParameter>
  <!--if specified the default option will be changed to automatically use the existing shared folder at the specified path-->

  <InstallParameter id="InstallationType">Everybody</InstallParameter>
  <!--valid values are "Current User" and "Everybody"-->
  <!--Determines the standard installation level-->
  <ApplicationSettings>
     <!--I want to know if this element contains at least one element -->
     <!--settings to override in settings.xml go here-->	
     <Custom Name="SaveAsFormatting">Off</Custom>
     <Custom Name="ContactManager_Username">testUser</Custom>
     <Custom Name="ContactManager_Password">password</Custom>
     <Custom Name="MatterCode_Definition">[MatterCode]</Custom>
     <Custom Name="DefaultSubjectName">{CaseNumber_MatterName}</Custom>
     <DefaultFileName>{Document.OurReference} {MatterData.MatterCode} {Document.Subject}</DefaultFileName>
  </ApplicationSettings>
</Configuration>
what I need is a function that can tell me if <ApplicationSettings> has a child (even when <ApplicationSettings> itself does not exist).
Please let me know if I missed a function or if this is somthing you will look into.

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Check if XML element has any children

Fri Jun 27, 2014 2:59 pm

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

I'm afraid we don't have predefined XML search for this scenario. We have added this improvement on our TODO list and maybe it will be available in a future version of Advanced Installer. Thank you for your suggestion.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

jokr
Posts: 3
Joined: Wed Jun 25, 2014 1:51 pm

Re: Check if XML element has any children

Wed Jul 02, 2014 8:12 am

Thank you for your reply and for taking this feature into concideration.

I will look forward to future versions.
In the mean time I will just enjoy the xml features that are already in Advanced Intaller.

Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Check if XML element has any children

Thu Nov 22, 2018 2:05 pm

Hello,

This improvement has been added in version 15.5 of Advanced Installer released on November 21st, 2018.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”