[erlang-questions] Re: xmerl and $'
Mark Fine
mark.fine@REDACTED
Mon May 24 21:34:55 CEST 2010
Huh? In my actual application, I've got lots of values being returned
in a single document -- I want to preserve these values, not
concatenate them altogether.
problem3() ->
Xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n<Keys><Key>There's a
problem</Key><Key>There&s another problem</Key></Keys>",
{Doc, _} = xmerl_scan:string(Xml),
[Value || #xmlText{value = Value} <-
xmerl_xpath:string("//Key/text()", Doc)].
returns ["There","'s a problem","There","&s another problem"] instead
of ["There's a problem","There&s another problem"]. And I definitely
don't want ["There's a problemThere&s another problem"].
So far, preprocessing the XML seems necessary -- I go through and map
' to __APOS__ and & to __AMP__ before xmerl_scan:string(),
and then map back -- this is the only way so far I've figured out how
to make this work.
Mark
On Mon, May 24, 2010 at 12:16 AM, Tim Fletcher <mail@REDACTED> wrote:
>> let me know how I should pre-process the XML to enable xmerl_scan
>> to handle things appropriately.
>
> Pre-processing the XML is unnecessary; just use lists:concat/1 or
> similar to combine the text values into a single string.
>
> Tim
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
More information about the erlang-questions
mailing list