473,396 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Deserialize elements to hashtable

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
Nov 28 '05 #1
2 2183
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
Nov 28 '05 #2
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.
Gabriel Lozano-Morán wrote:
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

Dec 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Denis Perelyubskiy | last post by:
Hello, I need to make an array of elements accross forms. My javascript skills, as evident from this question, are rather rudimentary. I tried to make an associative array and index it with...
1
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
3
by: jw56578 | last post by:
I have an object that inherits from hashtable and is serializable to be stored in the viewstate, but when I retrieve it from viewstate, it is converted into a hashtable, why won't it stay as the...
2
by: Michael | last post by:
Hi All, I have something going wrong with the XmlTextReader. I have a function that reads the following XML example. For some reason the code is only getting two of the 3 Values elements. Here is...
1
by: Zorpiedoman | last post by:
The following code explains my problem. It works fine if I use a file stream, but not if I use a memory stream. What's the problem here? It must be something simple I am missing... Dim H As...
1
by: Martin Z | last post by:
I'm getting acquainted with the whole XML/XSD thing, and I've run into a wall. I have a tree of objects that I deserialize from XML for configuration reasons. I have generated XSD from the...
0
by: davsmith_shop | last post by:
Hopefully I can ask this question without regaling you kind people in too many gory details. Here's what I'm trying to do: - I have a local XML file with a .GPX extension which I downloaded from...
9
by: =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post by:
Hi, I have a schema that has an optional element, fieldTag4000Field. If the element is omitted from the XML request, when it is deserialized, it will be null when I check it - which is fine. ...
1
by: Prabodh | last post by:
My elements and attributes are qualified...I am unable to deserialize this xml...How do I structure my class so that I could deserialize...I get an exception --> <MyRoot urn:ABCD:abc> not expected......
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.