473,657 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use an existing XML Serializing tool, or write my own?

I'm confused. XML looks to be extremely simple to read and write (so
simple that I feel confidant I could program serialization and
deserailization from a DOM document in an about an hour), yet I see
many serializing tools available (Xerces and .NET's System.Xml appear
to be the most popular). What functionality do these tools provide
that makes them useful over rolling my own parser?

-- MJF
Jul 20 '05 #1
8 1755
hp*****@hpalace .com (M Jared Finder) writes:
I'm confused. XML looks to be extremely simple to read and write (so
simple that I feel confidant I could program serialization and
deserailizatio n from a DOM document in an about an hour),


Could you please take that time and post the result?
Jul 20 '05 #2
In article <c9************ *************@p osting.google.c om>,
M Jared Finder <hp*****@hpalac e.com> wrote:

% I'm confused. XML looks to be extremely simple to read and write (so
% simple that I feel confidant I could program serialization and
% deserailization from a DOM document in an about an hour),

If you want to have a non-conforming parser, you might be able to do it
in something like that time. If you're interested in being able to process
valid XML, just reading the spec takes an hour.

% to be the most popular). What functionality do these tools provide
% that makes them useful over rolling my own parser?

Apart from providing (in some cases) correct and widely tested parsers,
the widely available tools often provide support for other useful related
specs, like xpath, xslt, xpointer, and xlink.

--

Patrick TJ McPhee
East York Canada
pt**@interlog.c om
Jul 20 '05 #3
M Jared Finder wrote:
I'm confused. XML looks to be extremely simple to read and write (so
simple that I feel confidant I could program serialization and
deserailization from a DOM document in an about an hour),
I am sure that you really don't know the full scope of XML. It might be
easy to write a parser that can parse a very limited subset of XML and
use it for a specific application, but I don't see many reasons to do
that. The only reason I can actually think of is if you are e.g. using
an embedded system with 2k of each ram and rom that needs to parse a
limited set of XML files.
yet I see many serializing tools available (Xerces and .NET's
System.Xml appear to be the most popular). What functionality do
these tools provide that makes them useful over rolling my own parser?


Existing parsers use standard interfaces (DOM, SAX), deal with stuff
like different character encodings, DTDs, xslt, Schemas and whatnot,
have lots of features, are easy to use, general purpose, well optimized
and heavily tested. None of those could be done in one hour or anything
near one hour.

Jul 20 '05 #4
Rolf Magnus <ra******@t-online.de> wrote in message news:<ca******* ******@news.t-online.com>...
M Jared Finder wrote:
yet I see many serializing tools available (Xerces and .NET's
System.Xml appear to be the most popular). What functionality do
these tools provide that makes them useful over rolling my own parser?


Existing parsers use standard interfaces (DOM, SAX), deal with stuff
like different character encodings, DTDs, xslt, Schemas and whatnot,
have lots of features, are easy to use, general purpose, well optimized
and heavily tested. None of those could be done in one hour or anything
near one hour.


I'm relatively certain that I do not need to worry about DTDs or XSLT
or any character encodings other than ASCII. I just want a well
structured, human readable file format format. In this case, would
you say that XML is not the right tool for the task at hand? I'm
starting to think that way.

-- MJF
Jul 20 '05 #5
M Jared Finder wrote:
Existing parsers use standard interfaces (DOM, SAX), deal with stuff
like different character encodings, DTDs, xslt, Schemas and whatnot,
have lots of features, are easy to use, general purpose, well
optimized and heavily tested. None of those could be done in one hour
or anything near one hour.
I'm relatively certain that I do not need to worry about DTDs or XSLT
or any character encodings other than ASCII.


But it certainly doesn't hurt if that's supported by the xml parser. And
if you later find out that you want to reduce redundant information in
your xml files by using entities (defined in the DTD) or to support
foreign (non-ascii) languages, you don't need to adapt your parser to
it because it already handles that for you.
I just want a well structured, human readable file format format. In
this case, would you say that XML is not the right tool for the task
at hand?
It probably is the right tool. I wonder why you are obsessed with
thinking that you can only use XML for your job if you wrote your own
parser. Why would you put work into writing your own XML parser if
there are already lots of them available? Actually, it's one of the
reasons that make XML the right tool for the job: You don't need to
bother writing your own parser for it, since excellent parsers are
already available.
I'm starting to think that way.


I can't see why.

Jul 20 '05 #6
hp*****@hpalace .com (M Jared Finder) writes:
I'm relatively certain that I do not need to worry about DTDs or XSLT
or any character encodings other than ASCII. I just want a well
structured, human readable file format format. In this case, would
you say that XML is not the right tool for the task at hand? I'm
starting to think that way.


I am using a structured, human readable file format called
Unotal that is simplier than XML, while it has expressive
power (due to the possibility of structured attribute values)
and specific semantics (similar to RDF). (Elaborations on
request.) Some notes about it:

http://www.purl.org/stefan_ram/pub/unotal_en

Jul 20 '05 #7
In article <c9************ **************@ posting.google. com>,
M Jared Finder <hp*****@hpalac e.com> wrote:

% structured, human readable file format format. In this case, would
% you say that XML is not the right tool for the task at hand? I'm
% starting to think that way.

You don't say what the task at hand is, so it's hard to answer the
question.

What XML does for you is define the syntax of the data representation.
This can be tremendously helpful if you ever need to describe the
syntax to somebody else, since you can just say `it's an XML file
with this structure...' and go on to describe the element hierarchy.
If you never need to document your file structure, and if you feel
that you can write a parser for any file format you're likely to
need faster than you can learn the ins and outs of one of the existing
XML parsers, then it probably doesn't give you much.

Beware that using an XML-like syntax but not supporting all the details
doesn't give you anything. You don't want your documentation to say
`it's an XML file, except ...'.
--

Patrick TJ McPhee
East York Canada
pt**@interlog.c om
Jul 20 '05 #8
The real answer is that System.Xml saves you about 55 minutes :-)

You run xsd.exe passing in the schema for your XML and it generates classes
for you, let's say the top level class that comes out of this is called
"MyData", matching the top level element in your schema.

Then to deserialize the XML into memory you simply do the following:

XmlSerializer s = new XmlSerializer(t ypeof(MyData));
MyData data = (MyData)s.Deser ialize(new XmlTextReader(f ilename)

That's it !!

If you don't have a schema, then go to
http://www.gotdotnet.com/team/xmltools/ and download the XSD Infererence
engine which will cook up a schema based on one or more input XML files in a
flash. If you have a DTD and not an XSD, no problem, there's a DTD to XSD
converter in the gotdotnet user samples.

The downside is that it's probably not going to be as fast as if you wrote
all the serialization code by hand. The upside is it probably won't contain
as many bugs as the code you crammed out in an hour while wishing you didn't
have to do it :-) Lastly, the XmlSerializer does not support every wild and
crazy feature of the overbloated XSD standard. But it does handle the 80%
case.

Chris.

PS: don't waste your time on XML competitors. XML is here to stay.
"M Jared Finder" <hp*****@hpalac e.com> wrote in message
news:c9******** *************** **@posting.goog le.com...
I'm confused. XML looks to be extremely simple to read and write (so
simple that I feel confidant I could program serialization and
deserailization from a DOM document in an about an hour), yet I see
many serializing tools available (Xerces and .NET's System.Xml appear
to be the most popular). What functionality do these tools provide
that makes them useful over rolling my own parser?

-- MJF

Jul 20 '05 #9

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

Similar topics

15
5063
by: DesignGuy | last post by:
I've inherited a site that has 1000+ product pages that follow a similar layout. I would like to import these pages into a database for ease of future updating. The pages have the usual banners, navigation menus, etc. and other extraneous code that must be removed. Does software exist to import existing HTML pages into a database - even a rough import would work as I can massage the data later. Ideas/suggestions will be appreciated.
4
2726
by: Wayne Wengert | last post by:
I am still stuck trying to create a Class to use for exporting and importing array data to/from XML. The format of the XML that I want to import/export is shown below as is the Class and the code I am using to create a sample XML file. I am trying to dimension the ArrayOfJudgeEntity to have two sets of the JudgeTableEntity values. When I run the code I get an error that the XML is not correct. I jsut can't get my head around the array...
1
2082
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I created a couple of objects and serializing it into XML based upon the schema works perfectly. The XML / Schema looks something like this:
10
8276
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b) This way I have to write another "serializing" function for every new kind of struct I want to write, though. Is there a way to write functions that can write/read any struct to/from plain text format in a portable way?
6
3386
by: Rein Petersen | last post by:
Hi Folks! Here's a strange behaviour: Without a properties SET accessor (see code below), the property will not serialize. public class myObject {
2
3515
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: + More ways to contact me __________________________________________________________________
0
1092
by: RJN | last post by:
Hi I'm using XMlSerailizer to write certain content to file. If the file exists, I'm supposed to append the xml to the file. eg., <EmployeeList> <Employee></Employee> </EmployeeList>
47
3100
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to ensure that subsequent requests will be queued until the current request is completed? If not, can IIS be configured to use seperate processes to satisfy requests for a nominated ASP page? Thanks in advance.
12
4909
by: Cagdas Ozgenc | last post by:
Greetings, When directly serializing C++ structures to a file with the standard library functions giving the address of the data and length of structure using the sizeof operator, do I risk portability because of different compilers packing structures into different sizes or components of this structure to different address boundaries (for example placing in multiples of 4 on a 32bit system)? Once the file is serialized, does the same...
0
8310
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.