# How to parse an XML file in Homey app?

**URL:** <https://community.homey.app/t/how-to-parse-an-xml-file-in-homey-app/42198>\
**Category:** Developers\
**Tags:** app\
**Created:** [February 1, 2021, 7:46am UTC](https://community.homey.app/t/how-to-parse-an-xml-file-in-homey-app/42198 "2021-02-01T07:46:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fredrik\_Palsson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik_palsson/32/34467_2.png) [@Fredrik\_Palsson](https://community.homey.app/u/Fredrik_Palsson)\
**Post date:** [February 1, 2021, 7:46am UTC](https://community.homey.app/t/how-to-parse-an-xml-file-in-homey-app/42198/1 "2021-02-01T07:46:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [February 1, 2021, 8:30am UTC](https://community.homey.app/t/how-to-parse-an-xml-file-in-homey-app/42198/2 "2021-02-01T08:30:07Z")

</div>

> [@Fredrik\_Palsson](#):
>
> I’m developing an app and was thinking I should persist settings and config in 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`](https://apps-sdk-v2.developer.athom.com/Device.html#setStoreValue)).

---

<div class="post-metadata">

**Author:** ![Fredrik\_Palsson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik_palsson/32/34467_2.png) [@Fredrik\_Palsson](https://community.homey.app/u/Fredrik_Palsson)\
**Post date:** [February 1, 2021, 7:53pm UTC](https://community.homey.app/t/how-to-parse-an-xml-file-in-homey-app/42198/3 "2021-02-01T19:53:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [February 2, 2021, 6:22am UTC](https://community.homey.app/t/how-to-parse-an-xml-file-in-homey-app/42198/4 "2021-02-02T06:22:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fredrik\_Palsson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik_palsson/32/34467_2.png) [@Fredrik\_Palsson](https://community.homey.app/u/Fredrik_Palsson)\
**Post date:** [February 2, 2021, 6:13pm UTC](https://community.homey.app/t/how-to-parse-an-xml-file-in-homey-app/42198/5 "2021-02-02T18:13:02Z")

</div>

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.
