Reputation: 103
I want to modify the values in an XML file in a Flutter app.
The XML looks something like this:
<Alarm>
<Type>ReallyLoudAlarm</Type>
<Issue>2</Issue>
<Revision>5</Revision>
<Settings>
<AlarmVolume type="int" min="0" max="100" unit="%">80</AlarmVolume>
<AlarmEnabled type="bool"> 1 </AlarmEnabled>
<AlarmMessage type="str" maxLen="20">Wake up</AlarmMessage>
</Settings>
</Alarm>
Which I am parsing with this XML parser and reading the values into my UI.
I would just like to update the value of an element by doing something like document.findAllElements('AlarmVolume').first.text = number.toString();
.
Am I just missing the way to do this, or do I have to rebuild the entire XML file when I save my form?
Upvotes: 3
Views: 1851
Reputation: 8947
<Settings>
and <Alarm>
have no (matching) closing tag.XmlElement.text
is a readonly property, but XmlElement.innerText
can be used to replace the text contents.document.toXmlString()
.Upvotes: 2