Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XML DOM methods use linefeed only without a carriage return at the end of a line


Summary

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 of the DOM object is excluded from this change.

↑ Back to the top


More Information

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&#xD;&#xA;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);

↑ Back to the top


References

For information about XML, visit the following W3C website:

↑ Back to the top


Keywords: kbdsupport, kbinfo, kbbillprodsweep, kb

↑ Back to the top

Article Info
Article ID : 261293
Revision : 1
Created on : 1/7/2017
Published on : 2/14/2011
Exists online : False
Views : 394