473,394 Members | 1,746 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,394 software developers and data experts.

XML as a stream protocol.

Hello,

We're redesigning a custom binary application protocol built on TCP
and I thought we should evaluate some XML options. I have a few
questions on how to best handle a stream of XML data.

The first option I looked at is similar to XMPP. After looking at
XMPP we may be able to use some of it, but since we'd end up writing
our own implementation we are not worried about sticking to a spec.
So, our first option would use a complete document in each direction
as the whole connection.. eg)

<connection>
<message>
...
</message>
...
</connection>
close socket.

What is the best parse model for this? Because the <messages> are
never going to be that big, DOM would be nice b/c it seems simpler to
code. But can DOM be applied to just a section of the whole document?
Is our only (standard) option here to use SAX?

The other option I thought of is to add some framing so each message
is its own document..

NUMBER_OF_BYTES\r\n
<message>
...
</message>

Where NUMBER_OF_BYTES is the length of the following "document" so it
can be read in from the socket then passed to a DOM parser.

So what is the better way? What works better with the available XML
parsers? Our applications are writtin in Python, C and Java.

Sorry if this is all basic, but my XML experience is not about 2 days
old.

Thanks.
Jul 20 '05 #1
1 1290
In article <87************@syn.codemonkey.net>, <jb****@yahoo.com> wrote:

[...]

% So, our first option would use a complete document in each direction
% as the whole connection.. eg)

[...]

% What is the best parse model for this? Because the <messages> are
% never going to be that big, DOM would be nice b/c it seems simpler to
% code. But can DOM be applied to just a section of the whole document?

DOM parses the entire document before giving the tree back to you.

% Is our only (standard) option here to use SAX?

Standard is a relative term, but yes.
% The other option I thought of is to add some framing so each message
% is its own document..

% NUMBER_OF_BYTES\r\n
% <message>
% ...
% </message>

I like this approach better. Each message really _is_ its own document,
so it ought to be represented as such.

% So what is the better way? What works better with the available XML
% parsers? Our applications are writtin in Python, C and Java.

Using python, you'll probably want to use libxml as the parser, and you
might as well also use it for C. This approach will work well with
the parser -- you hand it a buffer with the document in it, and it
hands you a tree back. With java, there's more standardisation, and
any parser ought to handle it OK.

--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #2

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

Similar topics

8
by: Scott | last post by:
Hi guys, If I try to call read(), readline(), readtoend() and there is nothing to read (from a never ending loop for example) the program seems to continue but it exits the loop for no apparent...
3
by: Helge Jensen | last post by:
I am implementing a protocol which transmits messages. The messages are most naturally transferred using the a Stream so the protocol can communicate over serial-ports, network links, .... If...
7
by: simonrigby_uk | last post by:
Hi all, Sorry if this is the incorrect group but I couldn't see anything directly relevant. Can someone confirm for me what happens when two network streams are sent to an application at the...
2
by: K.H. | last post by:
Hi Does anyone know how I can grab a video stream from an IP-address? There's a video web server for live image transmission in the Internet. Data transfer is accomplished via TCP/IP. The web cam...
4
by: Helge Jensen | last post by:
In C# 2.0 System.IO.Stream is declared as: public class Stream: ..., IDisposable { ... public void Dispose(); public void Dispose(bool); IDisposable.Dispose(); } Which must be a...
1
by: Ryan Liu | last post by:
Hi, As I remember theare are In and Out stream associate with a socket. TcpClient seems there in only one NetworkStream to do both read and write. Then will it be a conflicit if both side try...
7
by: Sanyi | last post by:
What is cin's streambuffer's state and content after the following (using namespace std)? string((istreambuf_iterator<char>(cin)), istreambuf_iterator<char>()) ); I am trying to use this in a...
10
by: =?Utf-8?B?SnVhbg==?= | last post by:
Hi! I want to use ASP to download big files using ADODB.STREAM. It works very fine with files smaller than 80 MB. On the Webserver I can see that memory allocation and the process w3wp is...
20
by: tomPee | last post by:
Hi, I've bumbed into a slight problem now, and I just don't seem to know how to fix it. What I want to do is the following: Send over a socket: 1. Number of files to be send (not as an integer,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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...
0
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...

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.