{"action":"created","issue":{"url":"https://api.github.com/repos/nfarina/xmldoc/issues/43","repository_url":"https://api.github.com/repos/nfarina/xmldoc","labels_url":"https://api.github.com/repos/nfarina/xmldoc/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/nfarina/xmldoc/issues/43/comments","events_url":"https://api.github.com/repos/nfarina/xmldoc/issues/43/events","html_url":"https://github.com/nfarina/xmldoc/pull/43","id":197476285,"number":43,"title":"Fix CData overwriting bug","user":{"login":"calebmer","id":8282507,"avatar_url":"https://avatars.githubusercontent.com/u/8282507?v=3","gravatar_id":"","url":"https://api.github.com/users/calebmer","html_url":"https://github.com/calebmer","followers_url":"https://api.github.com/users/calebmer/followers","following_url":"https://api.github.com/users/calebmer/following{/other_user}","gists_url":"https://api.github.com/users/calebmer/gists{/gist_id}","starred_url":"https://api.github.com/users/calebmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calebmer/subscriptions","organizations_url":"https://api.github.com/users/calebmer/orgs","repos_url":"https://api.github.com/users/calebmer/repos","events_url":"https://api.github.com/users/calebmer/events{/privacy}","received_events_url":"https://api.github.com/users/calebmer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-24T20:21:31Z","updated_at":"2016-12-25T07:22:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nfarina/xmldoc/pulls/43","html_url":"https://github.com/nfarina/xmldoc/pull/43","diff_url":"https://github.com/nfarina/xmldoc/pull/43.diff","patch_url":"https://github.com/nfarina/xmldoc/pull/43.patch"},"body":"I have some XML that looks like this:\r\n\r\n```xml\r\n      <content:encoded>\r\n<![CDATA[<a name=\"How.to.meet.someone.new\"></a>\r\n<h1>How to meet someone new</h1>\r\n\r\n<a name=\"L.and.make.them.like.you.\"></a>\r\n<h2>(and make them like you)</h2>\r\n\r\n<ul>\r\n<li>Smile</li>\r\n<li>Be inquisitive, ask thoughtful questions</li>\r\n<li>body language, mirroring</li>\r\n<li>Be open to peoples POV</li>\r\n<li>What are your Goals when meeting someone new?</li>\r\n</ul>\r\n\r\n]]>\r\n      </content:encoded>\r\n```\r\n\r\nWhich is valid XML. However, when parsed by `xmldoc` the `val` property for the `content:encoded` element is: `'\\n      '`. This is because the white space (in this case `'\\n      '`) emits a `text` event in the SAX parser after a `cdata` event has already been emit. So the `text` event overrides the `cdata` event even though `isValCdata` is true. This behavior seems to be very fault intolerant for what is acceptable by most other XML parsers. As another note, this behavior also makes XML that looks like `<a>b<c/>d</a>` very difficult to work with.\r\n\r\nThis PR changes the behavior of this library so that comments, cdata, and text may all be treated as XML nodes similarly to the `XMLElement` object. The `val` property is still maintained for convenience by appending cdata and text values, but to get comments you now have to look at the `children` array.\r\n\r\nThe breaking changes that occur because of this change:\r\n\r\n- No more `isValCData` or `isValComment`. An element can have more then one child node type.\r\n- Comments are no longer added to `val`. You can find them in `children` instead.\r\n- The `children`, `firstChild`, and `lastChild` properties may be a text, cdata, comment, or element object and not just an element object as they were in the past. To help filter out the objects you don’t want, use the new `type` property.\r\n\r\nIf you only use the convenience methods, nothing should change for you.\r\n\r\nThere are simpler ways to fix the bug I expressed above, I just feel like this is an important change to make for the stability of this library given it may cause other bugs.\r\n\r\nThanks so much for your work, this is a great library 👍 "},"comment":{"url":"https://api.github.com/repos/nfarina/xmldoc/issues/comments/269112876","html_url":"https://github.com/nfarina/xmldoc/pull/43#issuecomment-269112876","issue_url":"https://api.github.com/repos/nfarina/xmldoc/issues/43","id":269112876,"user":{"login":"nfarina","id":117280,"avatar_url":"https://avatars.githubusercontent.com/u/117280?v=3","gravatar_id":"","url":"https://api.github.com/users/nfarina","html_url":"https://github.com/nfarina","followers_url":"https://api.github.com/users/nfarina/followers","following_url":"https://api.github.com/users/nfarina/following{/other_user}","gists_url":"https://api.github.com/users/nfarina/gists{/gist_id}","starred_url":"https://api.github.com/users/nfarina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfarina/subscriptions","organizations_url":"https://api.github.com/users/nfarina/orgs","repos_url":"https://api.github.com/users/nfarina/repos","events_url":"https://api.github.com/users/nfarina/events{/privacy}","received_events_url":"https://api.github.com/users/nfarina/received_events","type":"User","site_admin":false},"created_at":"2016-12-25T07:22:54Z","updated_at":"2016-12-25T07:22:54Z","body":"At first glance this looks like a really great overhaul that will make a lot of folks very happy :) I will look more in depth this week!"}}
{"actor":{"display_login":"nfarina"}}