XML parsing memory overhead concerns

Paul Miller stele at fxtech.com
Fri Dec 17 14:23:01 GMT 1999


> Thanks James.  I think I got it.  You use the
> expat events to build the queue, and the use
> the call-backs to process the queue.  When
> the queue is empty, you ask expat to load
> the queue with the next chunk of the source.
> This should work like a charm -- and in a
> single thread.
> 
> Oh How Pretty!

Yes, I think so. This sounds exactly like what I was trying to do.
Perhaps my implementation was flawed. The problem occurred when I got to
some element data and wanted to "pull" that from within an element
handler.

Say I get called for an element "Point" which has this syntax:

	<Point>(x,y)</Point>

When I get to the handler, I'd like to write this:

void PointHandler(XML::Element &elem, Point *point)
{
	// "pull" a chunk of element data, but it'll automatically
	// stop when it gets to the end of the element (it stops
	// when it sees </Point>)
	char buf[40];
	elem.GetData(buf, sizeof(buf));
	sscanf(buf, "%dx%d", &point->x, &point->y);
}

For some reason I couldn't figure out how to make this work, because
with expat I might have hit the element but not necessary gotten to the
character data handler.

I think this will make a lot more sense once I release the code. And
fortunately, I could rewrite the internals (once I figure out how) to
once again layer over expat, without changing the interface.

--
Paul Miller - stele at fxtech.com

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list