{"action":"closed","issue":{"url":"https://api.github.com/repos/isaacs/sax-js/issues/154","labels_url":"https://api.github.com/repos/isaacs/sax-js/issues/154/labels{/name}","comments_url":"https://api.github.com/repos/isaacs/sax-js/issues/154/comments","events_url":"https://api.github.com/repos/isaacs/sax-js/issues/154/events","html_url":"https://github.com/isaacs/sax-js/issues/154","id":91679267,"number":154,"title":"<root> element required?","user":{"login":"richb-hanover","id":1094930,"avatar_url":"https://avatars.githubusercontent.com/u/1094930?v=3","gravatar_id":"","url":"https://api.github.com/users/richb-hanover","html_url":"https://github.com/richb-hanover","followers_url":"https://api.github.com/users/richb-hanover/followers","following_url":"https://api.github.com/users/richb-hanover/following{/other_user}","gists_url":"https://api.github.com/users/richb-hanover/gists{/gist_id}","starred_url":"https://api.github.com/users/richb-hanover/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richb-hanover/subscriptions","organizations_url":"https://api.github.com/users/richb-hanover/orgs","repos_url":"https://api.github.com/users/richb-hanover/repos","events_url":"https://api.github.com/users/richb-hanover/events{/privacy}","received_events_url":"https://api.github.com/users/richb-hanover/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-29T03:01:55Z","updated_at":"2015-08-29T23:45:29Z","closed_at":"2015-08-29T23:45:29Z","body":"I had been playing with sax-js a while back, and I had code that worked beautifully (and simply) in November 2014. The current (npm 1.1.1) version doesn't work as well - and requires a workaround (see below). \r\n\r\nHere's the situation: My application creates a data stream containing a series of XML records that have this format:\r\n\r\n```xml\r\n<KC_version id=\"0\">1.5</KC_version>\r\n<KC_getproperty name=\"authtypes\" id=\"1\"/>\r\n<KC_setproperty name=\"clientversion\" id=\"2\">InterMapper RemoteAccess 5.7.1</KC_setproperty>\r\n<KC_getproperty name=\"version\" id=\"3\"/>\r\n... etc...\r\n```\r\nTo demonstrate the problem, place the XML above into the file testcommands.xml then run the program below. If you use the version of sax.js from November 2014 (sorry, I don't know what commit changed the behavior), the output will show one JSON entry per XML record. Using the npm 1.1.1 version, there's a JSON object created by the first XML record, and the remainder of the XML is treated as text. \r\n\r\nI can work around this by creating a Transform that injects \"\\<root>\" at the start of the stream, but this seems like a lot of work. Is there an option that will regain this previous behavior? (I can supply a diff of the two sax.js files.)\r\n\r\n```javascript\r\n/***\r\n * Test to show off changed behavior between 19Nov2014 sax.js and the npm 1.1.1 version\r\n * 25Jun2015 -reb\r\n ***/\r\n\r\nvar saxStream = require('sax').createStream(false, {lowercasetags: true});\r\nsaxStream.on(\"error\", function(e) {\r\n    console.log(\"saxStream got error: \" + e);\r\n});\r\nsaxStream.on(\"opentag\", function(node) {\r\n    console.log(\"saxStream got new tag: \" + JSON.stringify(node));\r\n});\r\n\r\nsaxStream.on(\"closetag\", function(tag) {\r\n    console.log(\"saxStream got closetag: \" + tag);\r\n});\r\n\r\nsaxStream.on(\"text\", function(data) {\r\n    console.log(\"saxStream got text: \" + data);\r\n});\r\n\r\ntry {\r\n    var fs = require('fs');\r\n    var s = fs.createReadStream('./testcommands.xml');\r\n    s.pipe(saxStream);\r\n}\r\ncatch (e){\r\n    console.log(\"Uh oh...\" + e);\r\n}\r\n```\r\nDesired (previous) behavior:\r\n```\r\nsaxStream got new tag: {\"name\":\"kc_version\",\"attributes\":{\"id\":\"0\"},\"isSelfClosing\":false}\r\nsaxStream got text: 1.5\r\nsaxStream got closetag: kc_version\r\nsaxStream got text: \r\n\r\nsaxStream got new tag: {\"name\":\"kc_getproperty\",\"attributes\":{\"name\":\"authtypes\",\"id\":\"1\"},\"isSelfClosing\":true}\r\nsaxStream got closetag: kc_getproperty\r\nsaxStream got text: \r\n\r\nsaxStream got new tag: {\"name\":\"kc_setproperty\",\"attributes\":{\"name\":\"clientversion\",\"id\":\"2\"},\"isSelfClosing\":false}\r\nsaxStream got text: InterMapper RemoteAccess 5.7.1\r\nsaxStream got closetag: kc_setproperty\r\nsaxStream got text: \r\n...\r\n```\r\nCurrent (npm 1.1.1) behavior:\r\n```\r\nsaxStream got new tag: {\"name\":\"kc_version\",\"attributes\":{\"id\":\"0\"},\"isSelfClosing\":false}\r\nsaxStream got text: 1.5\r\nsaxStream got closetag: kc_version\r\nsaxStream got text: \r\n<KC_getproperty name=\"authtypes\" id=\"1\"/>\r\n<KC_setproperty name=\"clientversion\" id=\"2\">InterMapper RemoteAccess 5.7.1</KC_setproperty>\r\n<KC_getproperty name=\"version\" id=\"3\"/>\r\n...\r\n```"}}