Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Microsoft.XMLDOM Performance

Posted on 2004-10-28
7
Medium Priority
?
561 Views
Last Modified: 2008-02-01
I have an ASP page in web application which loads some xml (from a string from another source) and then parses it in various ways to render data on the page.  This does not use XSL for various reasons.

I am using Set objXML = Server.CreateObject("Microsoft.XMLDOM")

I amaware that there are many Microsoft Com objects for doing the same task and wondered which one I should use for performance, multiple hits on the page etc.  If you could also tell me why a certain one is better to use that would be great too.

Thanks

Dave
0
Comment
Question by:daveamour
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 26

Expert Comment

by:rdcpro
ID: 12437676
I would certainly not use that one for Server side work!  It's ancient.

Use:

Set objXML = Server.CreateObject("Msxml2.DomDocument.4.0")

or a little slower, a little older, but still supports the old 1998 XSL Patterns syntax:

Set objXML = Server.CreateObject("Msxml2.DomDocument")

I would also avoid using strings.  Use IStream.  Much safer (no encoding problems) and it's faster and uses fewer server resources.



Regards,
Mike Sharp

0
 
LVL 26

Accepted Solution

by:
rdcpro earned 200 total points
ID: 12437791
Oh, and if you do anything with W3C XML Schema, you pretty much have to stick with the newer MSXML 4.0. which is the first progID I posted:

Set objXML = Server.CreateObject("Msxml2.DomDocument.4.0")

0
 
LVL 19

Author Comment

by:daveamour
ID: 12441896
Ok thanks

What is IStream though?

My actual xml is coming from an existing VBScript Function which grabs data from another server and returns it as a string.

Thanks

Dave
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:rdcpro
ID: 12446208
An example of using IStream would be, instead of:

strXml = objXML.xml
Response.write(strXml)

you would use:

objXML.save(Response)

And instead of

objXML.loadXML(strInputXML)

you would use:

objXML.load(xmlHTTP.responseBody)

The load and save methods use a stream interface.  It depends on how your VBScript function works, but there's probably a more efficient way than serializing to a string, then loading the string into the DomDocument object.

Is this VBScript function by any chance using the ServerXMLHTTPRequest object?

Regards,
Mike Sharp
0
 
LVL 19

Author Comment

by:daveamour
ID: 12461165
Ok thanks

My VBScript is using MSXML2.ServerXMLHTTP and is wrapped in a Function which returns svrXmlHttp.ResponseText

Is this good or bad?

Dave
0
 
LVL 26

Expert Comment

by:rdcpro
ID: 12465734
Instead of

        objXML.loadXML svrXmlHttp.ResponseText

you can either directly assign the DOM object, like:

        objXML = srvXmlHttp.ResponseXML

In fact, unless you're going to do something else with the XML so that you need a separate DomDocument object, you can treat ResponseXML as a DomDocument object itself.  For example, to transform using XSLT, and send the results to the client:

srvXmlHttp.ResponseXML.tranformNodeToObject(objXsl, Response)

Direct assignment is pretty efficient, but some servers seem to mess up the response in some way or another so that ResponseXML doesn't actually return a DomDocument Object.  I've never exactly figured out why, but I believe it's because the content-type is incorrectly set on the remote server.  Usually this works well, and if it works with a particular server, it should always work with it.  That is, it's not an intermittant type of failure.  Either a request to a server parses correctly into a DomDocument object, or it doesn't.  If it fails, you can always parse the stream or body as in the next examples.

You can load using IStream:

        objXML.load srvXmlHttp.ResponseStream

or you can load as an unsigned array of bytes:

        objXML.load srvXmlHttp.ResponseBody

Any of these is probably safer than using ResponseText, unless you're absolutely sure of the character encoding.


Regards,
Mike Sharp
0
 
LVL 19

Author Comment

by:daveamour
ID: 12470649
Ok thanks Mike, I'll go and have a play with these ideas.

Cheers

Dave
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question