Announcement

Collapse
No announcement yet.

Working with XML files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Working with XML files

    Hello.
    I am new to the forum and not advanced in SF, so I would appreciate your help very much.

    What I need to do is to insert a program path into my XML file after the install. Although I have already searched quite a lot I am having troubles with that. It works fine with INIFile.SetValue but somehow I am unable to repeat this with XML. Here is what I need to do (at least as far as I have understood):

    1. Search for the installed XML file after the install:
    XML.Load(SessionVar.Expand("%FolderA%".."\\AAA\\ex e.xml"));

    2. Insert my product path saved in a variable:
    XML.SetValue("Section1/Section2/Element", "%FolderA%\\BBB\\Program.exe", false);

    3. Save the changed XML file:
    XML.Save("%FolderB%".."\\exe.xml");


    No problems with step 1. In step 2 I am unable to insert the path, which is inside the %FolderA% variable, into the XML file. It simply shows as %FolderA%, not as a correct path. In step 3 same problems with setting correct variables to be able to save the file into the correct location...

    Finally I was even trying to save my file on my desktop using:

    SessionVar.Set("%Desktop%", "C:\Users\XNOTE\Desktop" );
    Desktopx = SessionVar.Expand("%Desktop%");
    XML.Save("Desktopx".."\\exe.xml");

    ...and obviously it did not work.

    Thank you in advance for any help!

  • #2
    No problems with step 1. In step 2 I am unable to insert the path, which is inside the %FolderA% variable, into the XML file. It simply shows as %FolderA%, not as a correct path. In step 3 same problems with setting correct variables to be able to save the file into the correct location...
    If you look carefully, you will see that you are expanding the session variable in step 1, and because of this it works. As you are not doing the required expansion in the other steps, they fail. Please read this FAQ before you proceed.

    The other problem is that it appears that you don't quite understand the difference between a string and a variable:
    Code:
    -- Desktopx is a variable, it receives the result from SessionVar.Expand()
    Desktopx = SessionVar.Expand("%Desktop%");
    
    -- "Desktopx" is a string, because it is in quotes
    MyString = "Desktopx".."\\exe.xml";
    -- MyString now contains "Desktopx\\exe.xml", a fixed string
    
    MyNewString1 = Desktopx .. "\\exe.xml";
    -- MyNewString1 will contain the result from SessionVar.Expand("%Desktop%") concatenated
    -- with the string "\\exe.xml"
    
    MyNewString2 = SessionVar.Expand("%Desktop%\\exe.xml");
    -- MyNewString1 will receive the same result as MyNewString1, but session variable expansion 
    -- and string concatenation is done in a single operation
    Ulrich

    Comment


    • #3
      Ulrich, thank you very much! Your suggestions fixed all my problems.

      Comment

      Working...
      X