[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: fastetst, string concatenation or DOM object?
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|