perfectxml.com
 Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
home » focus » msxml » ask a question » past questions & answers Thursday, 11 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: I noticed that MSXML DOM always adds carriage-return (#xD i.e 0D) and line-feed (#xA i.e 0D) at the end of XML document. Is there a reason for that; how to avoid this?
Asked By: Guest
Viewed: 3212
Answer: We were able to reproduce the problem that you reported.
    Dim objXMLDoc As New MSXML2.DOMDocument40
    Dim strXMLText As String
    
    strXMLText = "<ROOT/>"
    MsgBox Len(strXMLText)
    
    objXMLDoc.loadXML strXMLText
    MsgBox Len(objXMLDoc.xml)
With the above code, the first MsgBox reports 7, whereas the next one reports 9! If you create an XML file in notepad, and load it using MSXML DOM using load method, you'll see the same behaviour. If you just save the file (without any change to XML) using MSXML DOM save method, you'll see 2 bytes more in the XML file. If you now open this XML file in Visual C++ in binary mode, you'll see 0D 0A at the end. We'll continue researching into this issue to see if this behaviour is recommended by XML specification or if it is a bug in MSXML. We'll post the findings here.


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