{"action":"opened","issue":{"url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/316","repository_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js","labels_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/316/labels{/name}","comments_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/316/comments","events_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/316/events","html_url":"https://github.com/Leonidas-from-XIV/node-xml2js/issues/316","id":169331701,"number":316,"title":"Is there a way to skip content when parsing? (NOT add it to the js output)","user":{"login":"pfid12","id":20815012,"avatar_url":"https://avatars.githubusercontent.com/u/20815012?v=3","gravatar_id":"","url":"https://api.github.com/users/pfid12","html_url":"https://github.com/pfid12","followers_url":"https://api.github.com/users/pfid12/followers","following_url":"https://api.github.com/users/pfid12/following{/other_user}","gists_url":"https://api.github.com/users/pfid12/gists{/gist_id}","starred_url":"https://api.github.com/users/pfid12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfid12/subscriptions","organizations_url":"https://api.github.com/users/pfid12/orgs","repos_url":"https://api.github.com/users/pfid12/repos","events_url":"https://api.github.com/users/pfid12/events{/privacy}","received_events_url":"https://api.github.com/users/pfid12/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-04T09:32:32Z","updated_at":"2016-08-04T09:32:32Z","closed_at":null,"body":"Background:\r\nI want to add an attribute to my xml which indicates the element's content is encrypted (`<password encrypted=\"true\">sdfhuirfe</password>`). If this is the case, the attribute/element processors for xml2js shall detect this and decrypt the content on the fly. \r\nThis works, however, I DON'T want the encrypted-attribute itself to carry over to the parsed js object, because the structure of the output object would be different.\r\n\r\nExample:\r\n`<user id=\"admin\"><password encrypted=\"true\">aaf9c645d794d1</password></user>\r\n`\r\nresults in:\r\n`{ id: 'admin', password: { _: 'test001', encrypted: true }}`\r\n(passwort of type object)\r\n\r\nWhile \r\n`<user id=\"peter\"><password>test002</password></user>`\r\nresults in:\r\n`{ id: 'peter', password: 'test002' }`\r\n(passwort of type string)\r\n\r\nAlso, for the decryption-detection I am currently doing the following:\r\n1) in the `attrValueProcessors` remember the value of the last attribute\r\n2) in the next `attrNameProcessors` check if the attribute name is 'encrypted' and the last value was `true`. If yes, remember some global \"encrypted=true\" variable\r\n3) in the next `valueProcessors` decrypt the value in case encrypted-variable is `true``\r\n\r\nIs there maybe more clever way to solve this?\r\n\r\nI use the following options:\r\n\r\n```\r\n\t\tlet parser = new xml2js.Parser({\r\n\t\t\texplicitArray: false,\r\n\t\t\tmergeAttrs: true,\r\n\t\t\tpreserveChildrenOrder\r\n\t\t\tattrNameProcessors: [\r\n\t\t\t\tcheckEncryption\t\t\t\t\r\n\t\t\t],\r\n\t\t\tattrValueProcessors: [\r\n\t\t\t\txml2js.processors.parseNumbers,\r\n\t\t\t\txml2js.processors.parseBooleans,\r\n\t\t\t\tcheckAttributeValue\r\n\t\t\t],\r\n\t\t\tvalueProcessors: [\r\n\t\t\t\tdecrypt,\r\n\t\t\t\txml2js.processors.parseNumbers,\r\n\t\t\t\txml2js.processors.parseBooleans\t\t\t\t\r\n\t\t\t]\r\n\t\t});\r\n```\r\n"}}
{"actor":{"display_login":"pfid12"}}