Homey Community Forum

How to parse an XML file in Homey app?

First of all, I’m a total javascript newbie. I have developed C# applications for as long as C# has existed.

I’m developing an app and was thinking I should persist settings and config in an XML structure. There is no problem setting as retreiving the settings using ManagerSettings.

My approach is to use the DOMParser, but I have problems accessing the parser (ReferenceError: DOMParser is not defined). Do I need to do a “require” something?

Is there a better way to save settings than to save everything as an XML structure?

That might be normal for C# apps, but for Javascript apps JSON is a much better fit. You should probably consider splitting up the settings and configuration into separate key/value’s instead of storing everything as a single JSON blob (for which ManagerSettings isn’t ideal, if you really want to take that route look at Device#setStoreValue).

Thanks, that worked well (with some disasters along the way).

Settings is not on a per device basis, but a lot of settings for the app, non device coupled. I guess I still need to use the ManagerSettings. I can’t find any way.

You also have the option to write (JSON) files to /userdata/.

Yes, I remember I read that somewhere before. Thanks for reminding.

Now I got the “Homey Offline” when trying to run my app. Kind of stuck, but that is material for a new thread.