By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,838 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,838 IT Pros & Developers. It's quick & easy.

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

P: n/a
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


Nov 11 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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:eg**************@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



Nov 11 '05 #2

P: n/a
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

Nov 11 '05 #3

P: n/a
"Sasha" <no@no.com> wrote in message
news:eg**************@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)
Nov 11 '05 #4

P: n/a
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.********@thona-consulting.com> wrote in message
news:OK**************@TK2MSFTNGP11.phx.gbl...
"Sasha" <no@no.com> wrote in message
news:eg**************@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)

Nov 11 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.