diff --git a/pretty-data.js b/pretty-data.js
index 6e53132..81244ff 100644
--- a/pretty-data.js
+++ b/pretty-data.js
@@ -65,8 +65,7 @@ function pp() {
pp.prototype.xml = function(text) {
- var ar = text.replace(/>\s{0,}<")
- .replace(/ //
if(ar[ix].search(/<\?/) > -1) {
- str += this.shift[deep]+ar[ix];
+ str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix];
} else
// xmlns //
if( ar[ix].search(/xmlns\:/) > -1 || ar[ix].search(/xmlns\=/) > -1) {
@@ -125,6 +124,10 @@ pp.prototype.xml = function(text) {
else {
str += ar[ix];
}
+ // remove excessive spaces
+ if (!inComment) {
+ str = str.replace(/\s+$/, '');
+ }
}
return (str[0] == '\n') ? str.slice(1) : str;
diff --git a/test/test_xml.js b/test/test_xml.js
index 7ac1322..dfc7eb2 100644
--- a/test/test_xml.js
+++ b/test/test_xml.js
@@ -1,5 +1,5 @@
-var xml = ' bbb ]]>',
+var xml = ' \n bbb \n ]]>',
pp_xml = require('../pretty-data').pd.xml(xml),
pp_xmlmin_com = require('../pretty-data').pd.xmlmin(xml,true),
pp_xmlmin = require('../pretty-data').pd.xmlmin(xml);