Hi,

I am using Mike Woodring's "Custom Configuration Section Handler" example
at http://staff.develop.com/woodring/dotnet/#elementnormalcfghandler.

The main part is included below and shows how the Hybrid Dictionary is
recursivley filled with xml data from the config file.

public class GeneralCfgHandler : IConfigurationSectionHandler
{
  ReadOnlyNameObjectDictionary ParseSection( XmlNode section )
  {
    ReadOnlyNameObjectDictionary settingsCollection = new
ReadOnlyNameObjectDictionary();
    foreach( XmlNode childNode in section.ChildNodes )
    {
      if( (childNode.NodeType == XmlNodeType.Element) &&
 (childNode.HasChildNodes) )
      {
      if( childNode.ChildNodes[0].NodeType == XmlNodeType.Text )
      {
        settingsCollection.Add(childNode.Name, childNode.InnerText);
      }
      else if( childNode.ChildNodes[0].NodeType == XmlNodeType.Element )
      {
 settingsCollection.Add(childNode.Name, ParseSection(childNode));
     }
   }
 }
 settingsCollection.MakeReadOnly();
 return(settingsCollection);
}

I would like to retrieve the following xml :-

<UserSettings>
  <role>
    <name>Admins</name>
    <users>
      <user>
        <userID>1</userID>
        <userName>Whelank</userName>
 <screens>
   <pos1>1</pos1>
   <pos2>3</pos2>
 </screens>
       </user>
 <user>
        ...
        </user>
     </users>
   </role>
   <role>
   ...
   </role>
</UserSettings>

However, the IDictionary takes only unique keys and so when I try to add
the second instance of 'user' an error occurs. How can I store several
nodes with the same name?

Any help would be appreciated,

Kerry

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to