views:

51

answers:

1

Can ConfigurationElementCollection object contain for its elements another ConfigurationElementCollection objects?

I have this xml where testsection is section root:

<testsection>
    <head>
        <metaData>
            <metaGroup id="general">
                <meta name="Content-type" content="text/html; charset=utf-8" type="http-equiv" />
            </metaGroup>
            <metaGroup id="default">
                <meta name="something" content="test" type="name" />
            </metaGroup>
        </metaData>
    </head>
</testsection>

Is it possibly to create classes with ConfigurationSection, ConfigurationElement and ConfigurationElementCollection that can read above xml?

The problem is that when we are implementing ConfigurationElementCollection we can't define that element in collection is of type another ConfigurationElementCollection.

I can make it to work if configuration section is like this (without metaGroup elements):

<testsection>
        <head>
            <metaData>
                    <meta name="Content-type" content="text/html; charset=utf-8" type="http-equiv" />
                    <meta name="something" content="test" type="name" />
            </metaData>
        </head>
    </testsection>
A: 

I think that only ConfigurationElement objects can contain ConfigurationElementCollection objects (ConfigurationElementCollection must have for its parent ConfigurationElement). So I think that I can solve this problem if metaGroup would be ConfigurationElement and if I add a new ConfigurationElementCollection (metaGroupCollection) as parent of meta ConfigurationElement.

<testsection>
        <head>
            <metaData>
                <metaGroup id="general">
                  <metaGroupCollection>
                      <meta name="Content-type" content="text/html; charset=utf-8" type="http-equiv" />
                  </metaGroupCollection>
                </metaGroup>
                <metaGroup id="default">
                  <metaGroupCollection>
                      <meta name="something" content="test" type="name" />
                  </metaGroupCollection>
                </metaGroup>
            </metaData>
        </head>
    </testsection>
ztepsic