[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: fastetst, string concatenation or DOM object?

  • From: Jonathan Perret <jperret@n...>
  • To: xml-dev@l...
  • Date: Tue, 06 Nov 2001 18:08:26 +0100

mxxmlwriter vb6
Hi Peter,

Everybody will tell you that using the DOM is slower (and more verbose)
than string concats. This is mostly true, except that the worst case for
string
concatenation in VB is quite pathetic. Plus, you have to be extra careful to
generate well-formed XML, which mostly means escaping &,< and > (and
either ' or " in attribute values,depending on your choice of delimiters).
This can be done with the Replace$ function but you have to invoke it once
for each character you're escaping, which hurts when there's a lot of text.

The first problem (VB's slow concatenations) can be overcome by using
ADO 2.6's Stream object, with the added benefit that you can load a DOM
directly from it :

Dim s as New ADODB.Stream
Dim doc as New MSXML2.DOMDocument
s.Open
s.WriteText "<hello>world</hello>"
s.Position=0
doc.load s

(beware of ADO 2.5's Stream object, which won't work nicely with MSXML3).

If you're serious about generating XML in VB though, you'll want to look at
the MXXMLWriter class in MSXML3. You basically feed it SAX events
(startElement, characters, endElement...) and it generates well-formed XML
in a string or a Stream. Look up the article named
"Manually Building an XML Document with MXXMLWriter" in MSDN.

Hope this helps.
--Jonathan

----- Original Message -----
From: "Peter Thornqvist" <thornqvist_peter@h...>
To: <xml-dev@l...>
Sent: Tuesday, November 06, 2001 4:50 PM
Subject:  fastetst, string concatenation or DOM object?


> I would like to know which technic is the fastest, using string
> concatenation or the DOM (MSXML3) object to create a XML-string in VB6.
>



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.