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

  • Thread starter Thread starter Russell Jones
  • Start date Start date
R

Russell Jones

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.
 
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
 
Sasha said:
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.
 
Sasha said:
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)
 
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
 
Back
Top