tags:

views:

153

answers:

1

I'm trying to extract text from an xml node using Erlang's xmerl_xpath:

[include "xmerl.hrl"]

{Doc, _}=xmerl_scan:string("<node>Hello World</node>").

[#xmlText{value=Text}]=xmerl_xpath:string("//node/text()", Doc).

Text.

"Hello World"

Works fine for this simple example. Problem occurs when the text in the node element is very large, say 1MB; xmerl_scan:string works fine [ie the document parses okay], but trying to extract the text produces this error:

{{badmatch,[{xmlText,[{node,1}],1,[],"[large text here]"}]}}

I thought maybe

a) xmerl_scan:string produces a different document structure when the text size is very large

b) I've reached some kind of limit for the Erlang string length

Any ideas what might be happening ?

Thanks

+1  A: 

What was your actual error? I don't really see how this could be the cause, but Erlang strings do take a lot of space; the integer list implementation takes 8 bytes of memory per character.

ire_and_curses
Error as follows:{{badmatch,[{xmlText,[{node,1}],1,[],"[large text here]"}]}}
Justin
If it was a memory problem, loading the module itself would fail, wouldn't it?
Zed