Let’s say I had an xml file like this:
<items>
<item>
<id>1</id>
<name>Item 1</name>
<description>This is item 1</description>
<quantityLeft>10</quantityLeft>
</item>
... (more items)
</items>
I’d like to parse it into a C# dynamic, where the tag names (name, description, etc…) become the property on the dynamic (and contains the data within the tags).
Where I could then do a query .Where (i => i.id = 1) for specific items in the IEnumerable<dynamic>, make some changes, and then update the XML file.
The XML file won’t be too long, I just need it to act as a DB for a tiny app, where there will be no connectivity to an actual RDBMS.
You could load the XML file into an XDocument, copy each item to an ExpandoObject, manipulate that, copy the items back to an XDocument, and save to an XML file.
Load:
Manipulate:
Save:
I’m sure there are much better options though.