Skip to content

Commit 2ffc89f

Browse files
committed
check if xml.attributes is available before checking length.
1 parent e7c8242 commit 2ffc89f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/xml2json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
var root = {};
119119
if (typeof xml.attributes === 'undefined') {
120120
root[xml.nodeName] = xml2jsonImpl(xml, options);
121-
} else if (xml.attributes.length === 0 && xml.childElementCount === 0){
121+
} else if (xml.attributes && xml.attributes.length === 0 && xml.childElementCount === 0){
122122
root[xml.nodeName] = normalize(xml.textContent, options);
123123
} else {
124124
root[xml.nodeName] = xml2jsonImpl(xml, options);

0 commit comments

Comments
 (0)