{"action":"created","issue":{"url":"https://api.github.com/repos/drmohundro/SWXMLHash/issues/19","labels_url":"https://api.github.com/repos/drmohundro/SWXMLHash/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/drmohundro/SWXMLHash/issues/19/comments","events_url":"https://api.github.com/repos/drmohundro/SWXMLHash/issues/19/events","html_url":"https://github.com/drmohundro/SWXMLHash/issues/19","id":59089515,"number":19,"title":"Interleaving XML elements support","user":{"login":"niyue","id":27754,"avatar_url":"https://avatars.githubusercontent.com/u/27754?v=3","gravatar_id":"","url":"https://api.github.com/users/niyue","html_url":"https://github.com/niyue","followers_url":"https://api.github.com/users/niyue/followers","following_url":"https://api.github.com/users/niyue/following{/other_user}","gists_url":"https://api.github.com/users/niyue/gists{/gist_id}","starred_url":"https://api.github.com/users/niyue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niyue/subscriptions","organizations_url":"https://api.github.com/users/niyue/orgs","repos_url":"https://api.github.com/users/niyue/repos","events_url":"https://api.github.com/users/niyue/events{/privacy}","received_events_url":"https://api.github.com/users/niyue/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/drmohundro/SWXMLHash/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/drmohundro/SWXMLHash/milestones/1","html_url":"https://github.com/drmohundro/SWXMLHash/milestones/1.0","labels_url":"https://api.github.com/repos/drmohundro/SWXMLHash/milestones/1/labels","id":959146,"number":1,"title":"1.0","description":null,"creator":{"login":"drmohundro","id":43072,"avatar_url":"https://avatars.githubusercontent.com/u/43072?v=3","gravatar_id":"","url":"https://api.github.com/users/drmohundro","html_url":"https://github.com/drmohundro","followers_url":"https://api.github.com/users/drmohundro/followers","following_url":"https://api.github.com/users/drmohundro/following{/other_user}","gists_url":"https://api.github.com/users/drmohundro/gists{/gist_id}","starred_url":"https://api.github.com/users/drmohundro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drmohundro/subscriptions","organizations_url":"https://api.github.com/users/drmohundro/orgs","repos_url":"https://api.github.com/users/drmohundro/repos","events_url":"https://api.github.com/users/drmohundro/events{/privacy}","received_events_url":"https://api.github.com/users/drmohundro/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":1,"state":"open","created_at":"2015-01-31T02:38:31Z","updated_at":"2015-02-26T15:46:11Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-02-26T15:35:26Z","updated_at":"2015-02-26T15:47:43Z","closed_at":null,"body":"Hi David, \r\n\r\nThanks for the library, I like the API of this library but have one feature request (or bug report?) on it.\r\n\r\nIn some XML documents, elements with the same name can appear in any order instead of appear continuously. For example, an XHTML document:\r\n```\r\n<html>\r\n  <body>\r\n    <p>one</p>\r\n    <div>two</div>\r\n    <p>three</p>\r\n    <div>four</div>\r\n  </body>\r\n</html>\r\n```\r\n\r\nAs you can see, tag p and tag div can interleave. And to parse and render this XHTML correctly, all the elements order in this document should be kept. So one-two-three-four should be shown in the browser instead of one-three-two-four. However, this seems not possible in current implementation. \r\n\r\nRight now, in current implementation, all child elements are stored in an ordered dictionary, whose key is the element name and value is an array of elements with the same element name. When adding an element, the new element will be appended to the dictionary entry with the element name, and when retrieving all children, the entire dictionary will be iterated entry by entry.\r\n\r\nIs there any plan to support the XML document with interleaving pattern like above? The current implementation seems to me incorrect when handling such interleaving pattern by giving me incorrect elements order because it will groups elements by their names first. \r\n\r\nTo support this interleaving pattern, we could simply use an array to replace the ordered dictionary, and this will not only make the implementation correct (XML document is essentially a linear document I think) but also much simpler. The only down side is the subscript access by element name will be slower but that may be acceptable. What do you think? "},"comment":{"url":"https://api.github.com/repos/drmohundro/SWXMLHash/issues/comments/76201313","html_url":"https://github.com/drmohundro/SWXMLHash/issues/19#issuecomment-76201313","issue_url":"https://api.github.com/repos/drmohundro/SWXMLHash/issues/19","id":76201313,"user":{"login":"drmohundro","id":43072,"avatar_url":"https://avatars.githubusercontent.com/u/43072?v=3","gravatar_id":"","url":"https://api.github.com/users/drmohundro","html_url":"https://github.com/drmohundro","followers_url":"https://api.github.com/users/drmohundro/followers","following_url":"https://api.github.com/users/drmohundro/following{/other_user}","gists_url":"https://api.github.com/users/drmohundro/gists{/gist_id}","starred_url":"https://api.github.com/users/drmohundro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drmohundro/subscriptions","organizations_url":"https://api.github.com/users/drmohundro/orgs","repos_url":"https://api.github.com/users/drmohundro/repos","events_url":"https://api.github.com/users/drmohundro/events{/privacy}","received_events_url":"https://api.github.com/users/drmohundro/received_events","type":"User","site_admin":false},"created_at":"2015-02-26T15:47:43Z","updated_at":"2015-02-26T15:47:43Z","body":"Great thought - the dictionary approach did make a few assumptions that were incorrect. Also, regarding the speed, I'm working on an optional lazy loading approach, which should mean that the speed shouldn't be a big deal, because it will only have the elements indexed that were requested."}}