Hello...Can I use an Array of Dictionary objects?
I have an XML which I would like to modify. The Data Structure that I am to use is this -
Dictionary<element, Dictionary<attr, value>>
element - is the Element which I am about to modify attr - the attribute whose value I am going to update value - the value with which I am to update
<Parents>
<Parent id="ParentA" description="New">
<Children>
<Child name="ChildA" />
</Children>
</Parent>
</Parents>
I would want to pass the following
Dictionary<string, string> dict_Attributes1=new Dictionary<string, string>();
Dictionary<string, string> dict_Attributes2=new Dictionary<string, string>();
dict_Attributes1.Add("id", "ParentB");
dict_Attributes1.Add("description", "Old");
dict_Attributes2.Add("name", "ChildB");
Dictionary<string, Dictionary<string, string>> dict_Elements = new Dictionary<string, Dictionary<string, string>>();
dict_Elements.Add(".", dict_Attributes1);//To update the Element
dict_Elements.Add("Children/Child", dict_Attributes2);//To update the Children's Attributes
Let us assume that I have already identified that I am to update Parent whose id is ParentA.
Now, here I am creating dict_Attributes1, dict_Attributes2 etc., is there a way I can have them stored in an (dynamic, size unknown at compile time) Array of Dictionary objects?
Alternatively, is there a better way of doing this - 1. Modify the attributes of a Selected XElement and its children's attributes?
EDIT
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<Environments>
<Environment id="Master" description="MasterSystem">
<Systems>
<DefaultSystem systemName="Master" server="http://localhost" />
</Systems>
</Environment>
</Environments>
</Configuration>
Now, when a user changes the id and description, I want to update this XML file with the new values. While changing the id and description (which are obtained from the user), I want to update the systemName as well with the same value of id.
If the new id is "Development" and description is "DevelopmentSystem",
The output XML should be
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<Environments>
<Environment id="Development" description="DeveloperSystem">
<Systems>
<DefaultSystem systemName="Development" server="http://localhost" />
</Systems>
</Environment>
</Environments>
</Configuration>