perfectxml.com
 Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
home » focus » msxml » ask a question » past questions & answers Friday, 12 October 2007
 
NEWS
MSXML 4.0 SP2 now available!

 
MSXML
Basics
DOM
SAX
XPath
XSLT
Schemas
SOM
HTTP Access
.NET
Data Islands
Ask a Question
   Past Q&As
C++ Samples
DLL/Version Info
Reference Guide
Books
KB Articles
   HOW TO
   SAMPLE
   INFO
   BUG/PRB
   FIX
   Misc.
MSXML Tips
   August 2002
   September 2002
MSXML Tools

Microsoft XML Core Services


Go back to list of previously asked questions and answers

Question: How do I find out the size (in bytes) for the XML document being parsed?
Asked By: Justus
Viewed: 1222
Answer: There are many ways to do this (no direct way though). Here is what we tried (all examples written using MSXML 4.0 SP 1 in Visual Basic 6.0):

    Dim objXML As New MSXML2.DOMDocument40
    objXML.async = False
    objXML.Load "c:\2.xml"
    MsgBox Len(objXML.xml)
Another approach would be to write the XML document to stream and get the stream size:

    Dim objXML As New MSXML2.DOMDocument40
    Dim objStream As New ADODB.Stream

    With objStream
        .Mode = adModeReadWrite
        .Open
    End With
    objXML.async = False
    objXML.Load "c:\books.xml"
    objXML.save objStream

    MsgBox objStream.Size
If are using SAX, you can easily use a counter variable and use it to count the number of characters. If you have any other ideas on how to achieve this, we would love to hear those, please email them to comments@perfectxml.com.


Go back to list of previously asked questions and answers
  Contact Us | E-mail Us | Site Guide | About PerfectXML | Advertise ©2004 perfectxml.com. All rights reserved. | Privacy