{"action":"created","issue":{"url":"https://api.github.com/repos/gniquil/sweet_xml/issues/8","labels_url":"https://api.github.com/repos/gniquil/sweet_xml/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/gniquil/sweet_xml/issues/8/comments","events_url":"https://api.github.com/repos/gniquil/sweet_xml/issues/8/events","html_url":"https://github.com/gniquil/sweet_xml/pull/8","id":96971353,"number":8,"title":"Add support to return values as strings.","user":{"login":"viniciussbs","id":245791,"avatar_url":"https://avatars.githubusercontent.com/u/245791?v=3","gravatar_id":"","url":"https://api.github.com/users/viniciussbs","html_url":"https://github.com/viniciussbs","followers_url":"https://api.github.com/users/viniciussbs/followers","following_url":"https://api.github.com/users/viniciussbs/following{/other_user}","gists_url":"https://api.github.com/users/viniciussbs/gists{/gist_id}","starred_url":"https://api.github.com/users/viniciussbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viniciussbs/subscriptions","organizations_url":"https://api.github.com/users/viniciussbs/orgs","repos_url":"https://api.github.com/users/viniciussbs/repos","events_url":"https://api.github.com/users/viniciussbs/events{/privacy}","received_events_url":"https://api.github.com/users/viniciussbs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-24T05:55:01Z","updated_at":"2015-08-01T15:31:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/gniquil/sweet_xml/pulls/8","html_url":"https://github.com/gniquil/sweet_xml/pull/8","diff_url":"https://github.com/gniquil/sweet_xml/pull/8.diff","patch_url":"https://github.com/gniquil/sweet_xml/pull/8.patch"},"body":"Values are char list as default. If we encode the response as JSON, it will be encoded as an array instead of a string. With values as strings, we can properly encode response as JSON. To ask for values as strings, just use the modifier `s`:\r\n\r\n    iex> doc = \"<foo>Bar</foo>\"\r\n    \"<foo>Bar</foo>\"\r\n    iex> doc |> xpath(~x\"/foo/text()\") |> Poison.encode\r\n    {:ok, \"[66,97,114]\"}\r\n    iex> doc |> xpath(~x\"/foo/text()\"s) |> Poison.encode\r\n    {:ok, \"\\\"Bar\\\"\"}\r\n    iex> doc |> xpath(~x\"/foo/text()\"l) |> Poison.encode\r\n    {:ok, \"[[66,97,114]]\"}\r\n    iex> doc |> xpath(~x\"/foo/text()\"ls) |> Poison.encode\r\n    {:ok, \"[\\\"Bar\\\"]\"}"},"comment":{"url":"https://api.github.com/repos/gniquil/sweet_xml/issues/comments/126928435","html_url":"https://github.com/gniquil/sweet_xml/pull/8#issuecomment-126928435","issue_url":"https://api.github.com/repos/gniquil/sweet_xml/issues/8","id":126928435,"user":{"login":"ptrckbrwn","id":4147775,"avatar_url":"https://avatars.githubusercontent.com/u/4147775?v=3","gravatar_id":"","url":"https://api.github.com/users/ptrckbrwn","html_url":"https://github.com/ptrckbrwn","followers_url":"https://api.github.com/users/ptrckbrwn/followers","following_url":"https://api.github.com/users/ptrckbrwn/following{/other_user}","gists_url":"https://api.github.com/users/ptrckbrwn/gists{/gist_id}","starred_url":"https://api.github.com/users/ptrckbrwn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptrckbrwn/subscriptions","organizations_url":"https://api.github.com/users/ptrckbrwn/orgs","repos_url":"https://api.github.com/users/ptrckbrwn/repos","events_url":"https://api.github.com/users/ptrckbrwn/events{/privacy}","received_events_url":"https://api.github.com/users/ptrckbrwn/received_events","type":"User","site_admin":false},"created_at":"2015-08-01T15:31:37Z","updated_at":"2015-08-01T15:31:37Z","body":"@viniciussbs, does this also solve the issue of xmerl returning an array of char lists when it hit's certain characters? This occurs especially often in escaped HTML.\r\n\r\nFor example:\r\n```elixir\r\niex> doc = \"<foo>&lt;img src=\\\"/img/pic.jpg\\\"/&gt;</foo>\"\r\n\"<foo>&lt;img src=\\\"/img/pic.jpg\\\"/&gt;</foo>\"\r\niex> doc |> xpath(~x\"//foo/text()\"l)\r\n['<img src=\"/img/pic.jpg\"/', '>']\r\n```"}}