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!

Jimmy
Posts: 36
Joined: Thu Apr 12, 2012 1:13 pm

XML- Search in a key-value structured xml

Using AI 9.6 I intend to do a search for some values in a "config- like" file:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sections>
  <section name="General">
    <item key="DatabaseServerName" value="localhost"/>
    <item key="DatabaseName" value="AnyDatabase"/>
    <item key="DatabaseUsername" value=""/>
    <item key="DatabasePassword" value=""/>
    <item key="Automatic" value="True"/>
  </section>
  <section name="Install">
    <item key="Components" value="11"/>
    <item key="ServerAsService" value="True"/>
    <item key="InstallFiles" value="True"/>
    <item key="InstallDatabase" value="True"/>
    <item key="ClearImportDatabase" value="False"/>
    <item key="ImportInitialData" value="False"/>
    <item key="AutoStartControl" value="True"/>
    <item key="ShortcutControl" value="True"/>
  </section>
  <section name="Upgrade">
    <item key="UpgradeDatabase" value="True"/>
    <item key="UpgradeFiles" value="True"/>
    <item key="SaveFilesBackup" value="True"/>
    <item key="SaveDatabaseBackup" value="True"/>
    <item key="UpgradeStructureOnly" value="True"/>
  </section>
</sections>
I tried several ways, with no success (maybe I'm too dumb ;)..?)

How can I get for example the value of the entry with the key Components?
Do you have an example with such generic xmls?

Thanks in advance
Jimmy
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: XML- Search in a key-value structured xml

Hello Jimmy,

In order to achieve what you want you can take a look on our "Creating a XML search" article.

Let us know if this helps, otherwise please give us more details about your scenario.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Jimmy
Posts: 36
Joined: Thu Apr 12, 2012 1:13 pm

Re: XML- Search in a key-value structured xml

Hi Daniel

Thanks a lot for your response!

My mistake: I did the test against following files:
  • [APPDIR]FileName.ini
  • "[APPDIR]FileName.ini"
  • "C:\Program Files (x86)\ProductName\FileName.ini"
if I use C:\Program Files (x86)\ProductName\FileName.ini, it seems to work (WITHOUT quotes "")

Sorry, my fault :oops:

Best regards and many thanks

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

Re: XML- Search in a key-value structured xml

You're welcome. I'm glad you got this working.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: XML- Search in a key-value structured xml

Hi guys,

Our config files have the same structure as your, could you please help me in getting a value, for example

<item key="Components" value="11"/>
<item key="SomeNumber" value="30"/>
<item key="AnotherValue" value="True"/>

How could we create an XML Search that saves "11" into a property?

If I search for attributeValue "Components", I can only save attributeName which will be "key".

If I create sevaral searches for attributeName "value", the attributeValue is always "11" (the first matching result from the file).

How could I save "11", "30", and "True" values into different properties?

Thanks in advance!

Best regards,
Zsolt
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: XML- Search in a key-value structured xml

Hello Zsolt,

Please find attached a sample which exemplifies a working example.
sample.zip
(3.36 KiB) Downloaded 456 times
Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 409
Joined: Fri May 29, 2015 10:36 am

Re: XML- Search in a key-value structured xml

Hi Daniel,

Thank you very much, you sample was really helpful!

Best regards,
Zsolt
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: XML- Search in a key-value structured xml

You are always welcome Zsolt.

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

Return to “Common Problems”