PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET What should I use : XMLDocument or Custom tree like data structure ?

Reply

What should I use : XMLDocument or Custom tree like data structure ?

 
Thread Tools Rate Thread
Old 17-09-2003, 06:36 PM   #1
Russell Jones
Guest
 
Posts: n/a
Default Re: What should I use : XMLDocument or Custom tree like data structure ?


There's little point in re-inventing the wheel. XML is extremely flexible
and you can write a schema to enforce the data structure and to help
validate the data itself, which can save you a huge amount of development
time. In addition, the .NET framework contains many pre-written (and
pre-tested) classes to manipulate XML, and not just as an in-memory DOM
tree. You can treat XML recursively, as with other tree structures. Finally,
XML and relational data are nearly interchangable via DataSets, which would
make it extremely easy to store the node data in a database, should you need
that capability. I'd recommend using XML.

"Sasha" <no@no.com> wrote in message
news:egYWK8TfDHA.2356@TK2MSFTNGP12.phx.gbl...
> Hi everyone,
>
> I would like to hear your opinions about a design solution I am
> contemplating.
>
> The problem I am following: Write an editor for a data structure that is
> recursive in nature. In other words it is a tree, where child nodes can
> contain links to parent nodes. And there multiple kind of nodes: Here is

an
> example
>
> Track 1
> Track 2
> Track 3
> Requirements
> Requirement
> Note
> Requirements
> Requirement
> Note
> Track 2 (reference)
> Requirement
> Requirements
> Requirement
> Note
> Track 1 (reference)
> Requirement
> Note
> Blah:
> And so on :
>
> The order of the elements is important. So, I need an easy way to swap

some
> elements for example.
> The data structure will be read from and saved to XML file.
>
> Here is my question: Should try to implement my own tree like structure or
> should I use XMLDocument and manipulate the data in the inmemory DOM tree?
> (Engine Class Collection pattern? )
>
> What are you ideas on this?
>
> I appreciate your input. Thank you in advance.
>
> Sasha
>
>
>
>
>
>
>
>



  Reply With Quote
Old 17-09-2003, 07:12 PM   #2
Sasha
Guest
 
Posts: n/a
Default What should I use : XMLDocument or Custom tree like data structure ?

Hi everyone,

I would like to hear your opinions about a design solution I am
contemplating.

The problem I am following: Write an editor for a data structure that is
recursive in nature. In other words it is a tree, where child nodes can
contain links to parent nodes. And there multiple kind of nodes: Here is an
example

Track 1
Track 2
Track 3
Requirements
Requirement
Note
Requirements
Requirement
Note
Track 2 (reference)
Requirement
Requirements
Requirement
Note
Track 1 (reference)
Requirement
Note
Blah:
And so on :

The order of the elements is important. So, I need an easy way to swap some
elements for example.
The data structure will be read from and saved to XML file.

Here is my question: Should try to implement my own tree like structure or
should I use XMLDocument and manipulate the data in the inmemory DOM tree?
(Engine Class Collection pattern? )

What are you ideas on this?

I appreciate your input. Thank you in advance.

Sasha








  Reply With Quote
Old 17-09-2003, 07:45 PM   #3
Oleg Tkachenko
Guest
 
Posts: n/a
Default Re: What should I use : XMLDocument or Custom tree like data structure?

Sasha wrote:

> Here is my question: Should try to implement my own tree like structure or
> should I use XMLDocument and manipulate the data in the inmemory DOM tree?
> (Engine Class Collection pattern? )

Depends on how your structure differ from XML and how you are going to use it.
The simplest way is XmlDocument, but it can limit you if you need more than
XML supports. Also if your structure is much simpler than XML, implementing
custom tree could benefit in memory and speed too.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

  Reply With Quote
Old 17-09-2003, 07:57 PM   #4
Thomas Tomicek [MVP]
Guest
 
Posts: n/a
Default Re: What should I use : XMLDocument or Custom tree like data structure ?

"Sasha" <no@no.com> wrote in message
news:egYWK8TfDHA.2356@TK2MSFTNGP12.phx.gbl...
> Hi everyone,
>
> I would like to hear your opinions about a design solution I am
> contemplating.
>
> The problem I am following: Write an editor for a data structure that is
> recursive in nature. In other words it is a tree, where child nodes can
> contain links to parent nodes. And there multiple kind of nodes: Here is

an
> example

....


Do you do anything with the data?

IF you do, forget the XML dom part.

Make classes, use XmlSerializer to reconstruct a class hierarchy from the
XML data (and to save the data out into a XML file).

I am doing a very complex editor for an O/R mapping framework at the
moment - tons of editor controls. It would have been impossible (as in: a
LOT more code) to do all this on top of a DOM model, which is just too
stupid internally.

I use XML as data structure externally, using XmlSerializer to construct the
classes. Works like a charm.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)


  Reply With Quote
Old 17-09-2003, 10:54 PM   #5
Sasha
Guest
 
Posts: n/a
Default Re: What should I use : XMLDocument or Custom tree like data structure ?

I agree with you. And that is the path I will follow. I don't know if I can
use XmlSerializer with recursive data structures; I am afraid I will have to
do it manually, which is not a big deal. But otherwise custom object is the
way go.

Thank you for your reply


"Thomas Tomicek [MVP]" <t.tomiczek@thona-consulting.com> wrote in message
news:OKPLP2UfDHA.1712@TK2MSFTNGP11.phx.gbl...
> "Sasha" <no@no.com> wrote in message
> news:egYWK8TfDHA.2356@TK2MSFTNGP12.phx.gbl...
> > Hi everyone,
> >
> > I would like to hear your opinions about a design solution I am
> > contemplating.
> >
> > The problem I am following: Write an editor for a data structure that is
> > recursive in nature. In other words it is a tree, where child nodes can
> > contain links to parent nodes. And there multiple kind of nodes: Here

is
> an
> > example

> ...
>
>
> Do you do anything with the data?
>
> IF you do, forget the XML dom part.
>
> Make classes, use XmlSerializer to reconstruct a class hierarchy from the
> XML data (and to save the data out into a XML file).
>
> I am doing a very complex editor for an O/R mapping framework at the
> moment - tons of editor controls. It would have been impossible (as in: a
> LOT more code) to do all this on top of a DOM model, which is just too
> stupid internally.
>
> I use XML as data structure externally, using XmlSerializer to construct

the
> classes. Works like a charm.
>
> --
> Regards
>
> Thomas Tomiczek
> THONA Software & Consulting Ltd.
> (Microsoft MVP C#/.NET)
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off