HISE Logo Forum
    • Categories
    • Register
    • Login

    Reading and Accessing XML files?

    Scheduled Pinned Locked Moved Solved General Questions
    8 Posts 4 Posters 342 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.
    • clevername27C
      clevername27
      last edited by

      I'm trying to read an XML file into memory, changing the data and writing it back out. Can youhelp with two questions?

      • The file's structure seem to come in OK, but not the data..
      • If the data was there, how would I access it?

      Thank you.

      The code to read the XML…

      HiseSnippet 718.3ocsU00aSCCE0tsFsV.IlD+.h1ScRipVXLlzDhw5GnJXaUKio81jmi6pUcribbJqBw+Y9G.Wmj0jBcSnJVdHJ2ON1Ge84dyHilwii0FDt94yi3H7yH9yU1IcmPEJzvdH7Fjy3z.tAcz7HZbLO.gwU+jKJtdMT5yO+vQTIUw3EtPnKzBF+KhPgsv6nC+rPJG.K24hvRYu6gCYZUWsTm.LoJoMJhxlRugeB0kVEBB+j9ABq13aoVdLBW6Hcvb+I5uoxx+BQr3ZI2YzA4CKTl6AZYfiwNuntSDxfQ2chiQvpLp37WM67+Rxwh.wB+E0gWjFvq.Q45Atxxzq5RzqSY50tD8VAkvknTsLJsIwmYDQ1hHN97TxPkkaFSgxdYpjkKpxTLoqFxPYaERmxGX.iEHZtW6163Au19fFMfRer0iFE0iZodu2afPx8mGa4gstgaSKgllkb1+1HpJV.n19.ubzgyuLT5xAvmuRNvomOm6la0iaDy3Amns7zn2FJ2xs6ynFO3678dw5zRpoA.oCysaB4NNQwrv95oUtk4TUysa78F0a7iFd+YnwiWYLWEwnkR3.spvNUo4g.1TkDdM2ri2LpLguHQ3pZ46ex8e+WVdxxtfJknVMTIrmFwU2mnEkeqBe80gtplSzj6CxKharBGEv83yfNvLITcROd7TqNB5A+K8Enr0AIRpcY4tqGOO.TCVRi4zQfBvNu7Lf+a8.+qTbSxHgkMY0brxJ3HTodL3X9jimS5OdLmYKHXMxfKebFSfNSmXEpaNlZMhaA81IIg9vvSFG1ckhKcZPbEmZIytsy1UA74pfTieAO4A63rw4A6bWPTHkYzWwxT9tYSaj5A3jJcrbcxwNauNnztA.Gocq1nPXL4ULl63+JP.uZLudMv7l0.ytqAl2tFX1aMv7t0.y9OHF2en9XhUGl0N.NF0OcDAF2WQAkUpJD8a.aOxKuA
      

      And the XML file…

      crash2 6 3 1 1 40 none condenser none none none none none crash1 6 2 1 1 40 none condenser none none none none none
      ustkU LindonL 2 Replies Last reply Reply Quote 0
      • ustkU
        ustk @clevername27
        last edited by ustk

        @clevername27 If the XML would have looked like this:

        <id>
            <name name="crash2"/>
            <drumcode code="6"/>
        </id>
        

        Then you would access data this way:

        Console.print(xmlData[0].id.name.name);
        
        // or get rid of the array part first:
        var data = xmlData[0];
        Console.print(data.id.name.name);
        
        

        Be careful because you have several id in the XML and they have no real id property so it will be hard to know which one you're looking at...

        But Dave is a much more qualified XML whisperer... 😛

        Can't help pressing F5 in the forum...

        d.healeyD 1 Reply Last reply Reply Quote 1
        • d.healeyD
          d.healey @ustk
          last edited by d.healey

          @ustk It seems the xml reader is quite limited. Try this snippet with any of the simple example xmls you'll find online and you'll see it doesn't really work.

          HiseSnippet 887.3ocsU0saSiDEdlzZDN6BZqDO.V8JmUYiRXYoHgPDZRCJZosQqAD2wNw93lQc7LVyLtznU8caej3M.NisahKD0sDo0WDky+ememYZULXLJMg5+1k4.g9ydQKk1EiVv3RxzwD5C8NlYrfNnh0gKyYFCjPnzcdsiA0eWR42me4gLASFCqYQHuWwig2vy310bmM7O4BwDVB7VdVCsexvowJ4HkPUf3YGu9jbV74ryfSXN0Z4Qn26nDtUoirLKXPcNTkrLZg5SxJ8eO2vmK.Gw.RD5nJ1jQK3hjYWmqFBgt6r0Y9NUY9i7NlmvWwecE3WJEDr1hl0.ZqaCRC9AfDsAj1sBR64EEq4410Rb34m7lJwFRJCK0MgRktjVGzxajB0PZ6kwNGlnQhUVD9z986Ff+z44saykBtDBRKjwVtRFnjysxIbA3rWqDgwprbkD8T2fKXhBnS6+osOOMHrlx2WnXIeHSDht6JziWG3y.6nqsMb+ZutemdFG+ReOhIDyw9a32FzMArUQwEemtQKwYxrdy0pOYfvFbv.OQIR.cSliAy4VUdmtAoLgA5Fr+u16xLw9cWEgvTLYPeWlbbyXHEieBx0kiN99WvzAnMAuHHsmCNXYMCgjKJtjG0.wuQIfd4ZNlzVsqZiVzoT5Us8upyy8aeU6FU6STV3TYUVgRB9VQooaTVcgRfI4lD61pz2lggxhr4ftYO0oHN1cyY46c2lkiq54MTTImJ41SygZ5xNRR0++9IeR8PC9u2McLyxbKC07P8xAsk6fCcLbAdMoZ0v2qtoVpa8jFgdeaozGVu3bXg0pjDdhyf5wLxkqN47umMb4Jhg+8PKbI5iG3EABH1FTpM2brJC8MSipRaARFVBbGDdCvzR2dmgcALUNSC3vsil78Kx3IDURgfYu4cE2AzZAXC5FKytEVogaW17.6Ovwl925wl6JD2yaF2FuXyXr0FvH159+.i0mnef2QooXmYM.20axG116w+Gg+uTEVt7riYVMGGY7NoHKBeYJFvnKkf.ctGska7shtui1UAh.YRIwWvuZgCbzzZgCtVHIiEqUeLtZsz8Hv8K4fXRV9lmO93KRGLfTtph140uWeRFN98w3XW5+a3F0ls4wagM+9VXyS1Ba9isvlmtE1bvVXyytUaba9upvpxpVGPFyNp7lEkdT4ogxoPxW4C3WFL
          

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          ustkU 1 Reply Last reply Reply Quote 3
          • ustkU
            ustk @d.healey
            last edited by

            @d-healey Effectively the results seem to vary. But if you build the XML yourself I imagine you can have the control on the results...

            Can't help pressing F5 in the forum...

            d.healeyD 1 Reply Last reply Reply Quote 1
            • d.healeyD
              d.healey @ustk
              last edited by

              @ustk Yes, but it still doesn't explain why the xml parser doesn't work with very basic xml files :p

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              1 Reply Last reply Reply Quote 2
              • LindonL
                Lindon @clevername27
                last edited by

                @clevername27 if you can I would ditch the XML in favour of JSON

                HISE Development for hire.
                www.channelrobot.com

                clevername27C 1 Reply Last reply Reply Quote 3
                • clevername27C
                  clevername27 @Lindon
                  last edited by

                  @Lindon I did and that this was the way forward - thank you.

                  1 Reply Last reply Reply Quote 1
                  • clevername27C
                    clevername27
                    last edited by

                    Thank you to the big three (@d-healey , @Lindon , @ustk). I moved ahead with using JSON files instead, which is a fine work-around. I'm marking as solved. Thank you, everyone.

                    1 Reply Last reply Reply Quote 0
                    • clevername27C clevername27 has marked this topic as solved on
                    • First post
                      Last post

                    57

                    Online

                    1.7k

                    Users

                    11.7k

                    Topics

                    101.8k

                    Posts