Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 261293 - Last Review: February 14, 2011 - Revision: 7.0
XML DOM methods use linefeed only without a carriage return at the end of a line
This article was previously published under Q261293
Versions of MSXML prior to 2.5 used both carriage return and linefeed (CRLF) characters to indicate the end of a line of text. However, starting with MSXML version 2.5, this behavior is different. Methods of the XML Document Object Model (DOM) now return text by using only the linefeed character. This change was made to comply with the World Wide Web (W3C) specification for how XML output should be generated. Note that the
xml property
(http://msdn.microsoft.com/en-us/library/ms755989(v=VS.85).aspx)
of the DOM object is excluded from this change.
To demonstrate this behavior, insert the following script into a new text file, save the file as XMLCRLF.js, and then double-click on the file. If the computer on which the file is being run has MSXML 2.5 or greater installed, the output text includes only a linefeed (ASCII 10) character. On computers that are using prior versions of MSXML, the output text includes a carriage return and a linefeed.
var str = "<root>a\r\nb
c</root>";
var doc = new ActiveXObject("MSXML2.DOMDocument.6.0");
doc.preserveWhiteSpace = true;
doc.loadXML(str);
var value = doc.documentElement.firstChild.nodeValue;
WScript.Echo("Text value of node: " + value);
var out = "";
for (i = 0; i < value.length; i++)
out += value.charCodeAt(i) + " ";
WScript.echo("ASCII character values of node: " + out);
For information about XML, visit the following W3C website:
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate