diff --git a/spec/stopNodes_spec.js b/spec/stopNodes_spec.js
index ec2da913..594c0ec5 100644
--- a/spec/stopNodes_spec.js
+++ b/spec/stopNodes_spec.js
@@ -414,4 +414,46 @@ describe("XMLParser StopNodes", function () {
// console.log(JSON.stringify(jObj, null, 4));
expect(jObj).toEqual(expected);
});
+ it("should parse attributes correctly for self closing stop node", function() {
+
+ const xmlData = ``;
+ const options = {
+ allowBooleanAttributes: true,
+ ignoreAttributes: false,
+ stopNodes: ["*.pre", "*.script"],
+ };
+ const expected = {
+ "script": ""
+ }
+ const parser = new XMLParser(options);
+ // console.log(JSON.stringify(parser.parse(xml)));
+
+ let result = parser.parse(xmlData);
+
+ // console.log(JSON.stringify(result,null,4));
+ expect(result).toEqual(expected);
+
+ });
+ it("should parse attributes correctly for self closing stop node", function() {
+
+ const xmlData = ``;
+ const options = {
+ allowBooleanAttributes: true,
+ ignoreAttributes: false,
+ stopNodes: ["*.pre", "*.script"],
+ };
+ const expected = {
+ "script": {
+ "@_src": "some.js"
+ }
+ }
+ const parser = new XMLParser(options);
+ // console.log(JSON.stringify(parser.parse(xml)));
+
+ let result = parser.parse(xmlData);
+
+ // console.log(JSON.stringify(result,null,4));
+ expect(result).toEqual(expected);
+
+ });
});
diff --git a/src/xmlparser/OrderedObjParser.js b/src/xmlparser/OrderedObjParser.js
index 7d1177f9..ffd3f24f 100644
--- a/src/xmlparser/OrderedObjParser.js
+++ b/src/xmlparser/OrderedObjParser.js
@@ -311,10 +311,18 @@ const parseXml = function(xmlData) {
let tagContent = "";
//self-closing tag
if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
+ if(tagName[tagName.length - 1] === "/"){ //remove trailing '/'
+ tagName = tagName.substr(0, tagName.length - 1);
+ jPath = jPath.substr(0, jPath.length - 1);
+ tagExp = tagName;
+ }else{
+ tagExp = tagExp.substr(0, tagExp.length - 1);
+ }
i = result.closeIndex;
}
//unpaired tag
else if(this.options.unpairedTags.indexOf(tagName) !== -1){
+
i = result.closeIndex;
}
//normal tag