diff --git a/pretty-data.js b/pretty-data.js
index 6e53132..31ad1b9 100644
--- a/pretty-data.js
+++ b/pretty-data.js
@@ -91,8 +91,12 @@ pp.prototype.xml = function(text) {
str += ar[ix];
inComment = false;
} else
+ // //
+ if(ar[ix].search(/\/>/) > -1) {
+ str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix];
+ } else
// //
- if( /^<\w/.exec(ar[ix-1]) && /^<\/\w/.exec(ar[ix]) &&
+ if( /^<\w/.exec(ar[ix-1]) && ar[ix-1].search(/\/>/) == -1 && /^<\/\w/.exec(ar[ix]) &&
/^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace('/','')) {
str += ar[ix];
if(!inComment) deep--;
@@ -109,10 +113,6 @@ pp.prototype.xml = function(text) {
if(ar[ix].search(/<\//) > -1) {
str = !inComment ? str += this.shift[--deep]+ar[ix] : str += ar[ix];
} else
- // //
- if(ar[ix].search(/\/>/) > -1 ) {
- str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix];
- } else
// xml ... ?> //
if(ar[ix].search(/<\?/) > -1) {
str += this.shift[deep]+ar[ix];
diff --git a/test/test_xml.js b/test/test_xml.js
index 7ac1322..532a915 100644
--- a/test/test_xml.js
+++ b/test/test_xml.js
@@ -1,5 +1,5 @@
-var xml = ' bbb ]]>',
+var xml = ' bbb ]]>',
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);