Announcement

Collapse
No announcement yet.

Write variable to XML file

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

  • Write variable to XML file

    Hello,

    I'm experimenting a little bit with XML.SetValue option and I have the following problem:

    xmlscenery = SessionVar.Expand("%MyDocumentsFolder%");
    -- You can then use this Lua variable to reference the file.
    XML.Load(xmlscenery.."\\Prepar3D v4 Add-ons\\TestAddon\\add-on.xml", "", SW_SHOWNORMAL);

    XML.SetValue("SimBase.Document/AddOn.Component/Path", SessionVar.Expand("%AppPath%\\Ecosystem\\Scenery"))

    xmlscenery = SessionVar.Expand("%MyDocumentsFolder%");
    -- You can then use this Lua variable to reference the file.
    XML.Save(xmlscenery.."\\Prepar3D v4 Add-ons\\TestAddon\\add-on.xml", "", SW_SHOWNORMAL);

    I set the variable on startup using this:

    SessionVar.Set("%AppFolder%", Registry.GetValue(HKEY_CURRENT_USER, "SOFTWARE\\Lockheed Martin\\Prepar3D v4", "AppPath", true));

    And would like to place it in StringValue with some additional paths after it in the XML file.

    What i get in final is just text. It may be probably easy to solve but I cant figure it out yet.

    Thank you,
    Mateusz

  • #2
    Originally posted by Matteusz View Post
    What i get in final is just text. It may be probably easy to solve but I cant figure it out yet.
    Could you show what output you are getting, and what you are expecting to get instead? It is hard to understand what a simple code fragment is supposed to do.

    Ulrich

    Comment


    • #3
      Hi,

      I attach xml file here.

      What I want to do is to take installation location from registry and insert it in specific place in my XML file.

      I've got the code almost working, but instead of path from registry I just get this: <Path>%AppPath%\Ecosystem\Publish\Product\Scenery</Path>

      I want to take it from:

      SessionVar.Set("%AppFolder%", Registry.GetValue(HKEY_CURRENT_USER, "SOFTWARE\\Lockheed Martin\\Prepar3D v4", "AppPath", true));

      Kind regards
      Attached Files

      Comment


      • #4
        Problem solved. Issue was the way I put Var.Expand

        Comment

        Working...
        X