RReverser / serde-xml-rs

xml-rs based deserializer for Serde (compatible with 1.0+)
https://crates.io/crates/serde-xml-rs
MIT License
269 stars 90 forks source link

Help with deserializing/serializing #178

Closed alakhpc closed 1 year ago

alakhpc commented 2 years ago

Hi!, I have a xml file with a structure like this

<?xml version="1.0" encoding="utf-8"?>
<Preferences Prop1="value1" Prop2="value2" />

I'd like to change the value of "Prop2" to something else and then write to another file

How would I do this, I tried Deserializing like this

serde_xml_rs::from_str::<HashMap<String, String>>(&xml_string)?

that gives me the values but I can't serialize it again into the same format, It comes out as

<Prop1>
value1
</Prop1>
<Prop2>
value2
</Prop2>

I dont want to make a struct since there are few hundred properties in the file and I only need to change 1 or 2