As an alternative to store user configs to database, I'm choosing now to store those configs inside a xml file. Using lxml
, I created the following (example):
<root>
<trigger name="trigger_a">
<config_a>10</config_a>
<config_b>4</config_b>
<config_c>true</config_c>
</trigger>
<trigger name="trigger_b">
<config_a>11</config_a>
<config_b>5</config_b>
<config_c>false</config_c>
</trigger>
</root>
So my intention is, giving the trigger name I would like, to get the related config. Something like this, as an example:
print getTriggerConfig('trigger_a')
Config a is: 10
Config b is: 4
Config c is: true
Thanks in advance.
EDIT: I dont want you guys to give me full solution. I found this link How to get XML tag value in Python which shows how I do it, but I created this post to see if there is something "cleaner" than the answer given. Also, I don't want to use BeautifulSoup
since I'm already using lxml
.