On Wed, 24 Sep 2008 07:38:01 -0700, Bart Steur
<BartSteur@discussions.microsoft.comwrote:
Quote:
>Ha Martin,
>
>Maybe I wasn't clear enough. I don't want a class representation of the XML
>itself, I want a class/collection structure that can create/maintain the
>following XML structure:
>
<category>
<attribute_n/>
...
<subcategory_n>
<attribute_n/>
...
</subcategory_n>
...
<attribute_n/>
...
<subcategory_n>
<attribute_n/>
...
</subcategory_n>
...
<attribute_n/>
...
</category>
>
>Within that class I want to add/remove attributes and subcategories and
>attributes within subcategories. The number of attributes within a category
>is unknown, the number of attributes with a subcategory is unknown, also the
>number of subcategories within a category is unknown.
>
>What does that class look like, and do I need collections, or something else.
>
The class will look a lot like the XmlNode type with a collection of
attributes and a collection of childnodes. It seems likely there will
be more than a single category. If this is the case the container
starts looking like an XML document.
Depending upon your actual needs you might consider writing a type
which maintains the data in a private/protected XmlDocument member.
The type's public methods provide a clean interface through which the
document and data may be manipulated. Private/protected helper methods
can perform the various CRUD operations behind the pretty interface.
i.e.
public class MyDataContainer
{
private XmlDocument doc;
...
public bool AddSubcategory(
string CategoryName,
string SubcategoryName,
string[] SubcategoryAttributes)
{...}
...
}
It may be possible to do something similar with the XDocument family.
regards
A.G.
Quote:
>I'm a little stuck.
>
>Thks,
>Bart
>
>"Martin Honnen" wrote:
>