HISE Logo Forum
    • Categories
    • Register
    • Login

    loadFromXmlFile - can't get it to work

    Scheduled Pinned Locked Moved General Questions
    4 Posts 3 Posters 104 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dan KorneffD
      Dan Korneff
      last edited by

      Am I doing something wrong? (probably)
      I'm trying to load data from an xml file and parse it to JSON. My code looks like this:

      var xmlData = File.loadFromXmlFile("path\to\file);
      

      But I'm getting the error

      Unknown function 'loadFromXmlFile'
      

      Dan Korneff - Producer / Mixer / Audio Nerd

      ? Matt_SFM 2 Replies Last reply Reply Quote 0
      • ?
        A Former User @Dan Korneff
        last edited by

        @Dan-Korneff Does this work? I don't have any JSON xml files to test but it doesn't return any errors:

        var xmlData;
        
        FileSystem.browse(FileSystem.AudioFiles, false, "*.xml", function(result)
        {
            xmlData = result.loadFromXmlFile();   
            //maybe some other step here? 
        });
        
        1 Reply Last reply Reply Quote 1
        • Matt_SFM
          Matt_SF @Dan Korneff
          last edited by

          @Dan-Korneff when it comes to file loading, you have to get a reference to the file first :

          const appData = FileSystem.getFolder(FileSystem.AppData); 
          const myXmlFile = appData.getChildFile("MyFile.xml");
          
          const xmlData = myXmlFile.loadFromXmlFile();
          

          The solution by @iamlamprey works too if you want to open the browser.

          Develop branch
          Win10 & VS17 / Ventura & Xcode 14. 3

          1 Reply Last reply Reply Quote 1
          • Dan KorneffD
            Dan Korneff
            last edited by

            Thanks guys!

            Dan Korneff - Producer / Mixer / Audio Nerd

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            47

            Online

            1.7k

            Users

            11.7k

            Topics

            101.8k

            Posts