Groups | Blog | Home
all groups > dotnet xml > november 2005 >

dotnet xml : Deserialize elements to hashtable


Gabriel Lozano-Morán
11/28/2005 11:41:16 AM
I am bit stuck here (it's monday and I am having probs concentrating).

I have the following Xml file:

<?xml version="1.0" encoding="utf-8" ?>
<preferences>
<groups>
<group name="group1">
<settings>
<setting name="setting1" value="value1" />
<setting name="setting2" value="value2" />
</settings>
</group>
<group name="group2">
<settings>
<setting name="setting1" value="value1" />
<setting name="setting3" value="value3" />
</settings>
</group>
</groups>
</preferences>

I want to deserialize the groups and settings to a class that implements the
NameObjectCollectionBase class. I can successfully deserialize to a
CollectionBase but then I need to access setting3 using integer indexes as
follows:
Preferences.Groups[0].Settings[0].Value;

I want to access the settings as follows:
Preferences.Groups["group1"].Settings["setting1"].Value;

Thanks

Gabriel Lozano-Morán

Gabriel Lozano-Morán
11/28/2005 4:40:58 PM
Forgot to mention that this is for .NET v1.1 also if there are any design
pattern for user profiles please let me know. The Xml file I mentioned can
be completely changed. I want to know if it is possible using the attributes
used in the System.Xml.Serialization namespace.

Gabriel Lozano-Morán

uttara
12/21/2005 5:12:54 PM
Sounds like you are deserializing the XSD into a class. Have you looked
at the option of deserializing it into a dataset by any chance? Please
ignore this if my assumption is incorrect.
I am not sure if this is a solution to your problem, but just a suggestion.


[quoted text, click to view]
AddThis Social Bookmark Button