473,516 Members | 3,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11 '05 #1
4 2759
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2042
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, class ARG_TYPE = const TYPE&> class CBTree : public CObject {
1
1742
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 parsing functions. Are there any examples or sample code that illustrates on how to go about building a custom XML parser on these lines. The main...
7
4879
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: Value of type System.xml.xmldocument cannot be converted to System.IO.textreader. I would think this is possible to do. Code snippet is below:
4
612
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 to have an API like this: Let Node be a suitably defined data structure. Then the following functions shall be supported:
4
1374
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 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
10
8770
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: org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation. at...
5
3696
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 normal tree. Now the thing is i can popullate my tree at compile time like a global data. Since i know my tree definition at compile time, instead...
8
1782
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 a slow distant site). - But you want to be able to request data from it, such has "give me all nodes that are under a "//foo/bar" tree, and have a...
0
2191
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 to a possibility of storing extra information in unused bits of the tree pointers (it works for linked lists too). One can say it is dangerous or...
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7405
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7574
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7547
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3265
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.