473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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


Nov 20 '05 #1
4 1119
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 20 '05 #2
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 20 '05 #3
"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 20 '05 #4
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 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Nobody | last post by:
I am trying to write a BTree class, just wondering if I missed any useful methods. This is my class definition so far (excuse the MFC portions, its a project requirement): template <class TYPE,...
4
by: Henry Jordon | last post by:
I have everything pretty much done but I need to fix something in my coding. I want to be able to enter strings such as "love", "hate", "the", etc. but am unable to figure how to do this. I have...
4
by: Sasha | last post by:
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...
1
by: RiceGuy | last post by:
Hi, I'm wondering on how to go about writing a simple XML parser, one that doesn't use the XmlDocument class (DOM API) and relies only on (in-built, so to say low-level) file system and string...
7
by: SQLScott | last post by:
I have a Web Service in which I am trying to pass an XMLDocument as a parameter to one of the methods. I would like to use the XMLTextReader to read the XML but I am getting the following error: ...
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
10
by: Simon Brooke | last post by:
The DOM API has included public Node importNode(Node,boolean) as a method of the Document interface for a long time. Does anything actually implement it? Xerces 2 is giving me: ...
5
by: hankypan1 | last post by:
Hi All, I need a tree data structure for my application. It is the non -cyclic simple tree where i can have any number of children node and each child can recursively become a sub tree like a...
8
by: =?ISO-8859-1?Q?m=E9choui?= | last post by:
Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from...
0
by: mac | last post by:
I found that with memory allocating techniques used nowadays (addresses alignment, eg. on 32bit machines) one can detect loops in a tree structure very fast, without using extra memory. This is due...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.