{"action":"created","issue":{"url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/236","labels_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/236/labels{/name}","comments_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/236/comments","events_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/236/events","html_url":"https://github.com/Leonidas-from-XIV/node-xml2js/issues/236","id":106802890,"number":236,"title":"TypeError: Cannot read property 'toString' of null","user":{"login":"maketroli","id":8395866,"avatar_url":"https://avatars.githubusercontent.com/u/8395866?v=3","gravatar_id":"","url":"https://api.github.com/users/maketroli","html_url":"https://github.com/maketroli","followers_url":"https://api.github.com/users/maketroli/followers","following_url":"https://api.github.com/users/maketroli/following{/other_user}","gists_url":"https://api.github.com/users/maketroli/gists{/gist_id}","starred_url":"https://api.github.com/users/maketroli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maketroli/subscriptions","organizations_url":"https://api.github.com/users/maketroli/orgs","repos_url":"https://api.github.com/users/maketroli/repos","events_url":"https://api.github.com/users/maketroli/events{/privacy}","received_events_url":"https://api.github.com/users/maketroli/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-09-16T15:50:56Z","updated_at":"2015-10-08T13:59:18Z","closed_at":null,"body":"I am trying to convert some XML to json\r\n\r\nI have here this into a function\r\n\r\n    var parseString = require('xml2js').parseString\r\n\r\n```javascript\r\ntoXml = function(dataset) {\r\n    var cancel, view, fillOpen;\r\n    _.map(dataset, function(items) {\r\n      return _.map(items, function(item) {\r\n        parseString(item.XX_CANCEL, function(err, res) {cancel = res;});\r\n        parseString(item.XX_VIEW, function(err, res) {view = res;});\r\n        parseString(item['XX_FILL OPEN'], function(err, res) {fillOpen = res;});\r\n        return item;\r\n      });\r\n    });\r\n  }\r\n```\r\nand when I try to call it\r\n\r\n```javascript\r\ntoXml(dataset).then(function(err, res) {\r\n   console.log('>>>>>>>>>>>>>>>>>>items', res);\r\n});\r\n````\r\nwhen I try to execute it, I get this error\r\n\r\n    /home/mretana/Documents/Projects/capilleiraclickandgamblebackend/node_modules/mssql/node_modules/tedious/node_modules/babel-runtime/regenerator/runtime.js:493\r\n            throw exception;\r\n                  ^\r\n    TypeError: Cannot read property 'toString' of null\r\n        at Parser.exports.Parser.Parser.parseString ...\r\n\r\njust for you to know, for example if I remove the `parseString(...)` and do \r\n\r\n    cancel = item.XX_CANCEL;\r\n\r\n    console.log(cancel)\r\n    logs ---> <element><element_type>BASIC_CHECKBOX</element_type><element_call/><element_content>1</element_content></element>\r\n\r\nit logs that XML element, that is why I am doing it with the `parseString`, \r\n\r\n    cancel = parseString(item.XX_CANCEL, function(err, res) {cancel = res;});\r\n\r\nso, what do you think is going on ?\r\n\r\nAll I need is to convert those XML elements into JSON.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/comments/146554052","html_url":"https://github.com/Leonidas-from-XIV/node-xml2js/issues/236#issuecomment-146554052","issue_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/236","id":146554052,"user":{"login":"krusk","id":4613931,"avatar_url":"https://avatars.githubusercontent.com/u/4613931?v=3","gravatar_id":"","url":"https://api.github.com/users/krusk","html_url":"https://github.com/krusk","followers_url":"https://api.github.com/users/krusk/followers","following_url":"https://api.github.com/users/krusk/following{/other_user}","gists_url":"https://api.github.com/users/krusk/gists{/gist_id}","starred_url":"https://api.github.com/users/krusk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krusk/subscriptions","organizations_url":"https://api.github.com/users/krusk/orgs","repos_url":"https://api.github.com/users/krusk/repos","events_url":"https://api.github.com/users/krusk/events{/privacy}","received_events_url":"https://api.github.com/users/krusk/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T13:59:18Z","updated_at":"2015-10-08T13:59:18Z","body":"Thank you both, and my apologies for miscoding as I wrongly thought fs could interpret it from my Webservice. Would it be worthwhile to show an example of calling from a web service on the homepage? Do you have any preferences."}}