[erlang-questions] xmerl_xpath difficulties

David Mitchell monch1962@REDACTED
Sun Aug 5 14:51:41 CEST 2007


Thanks Caoyuan, but it didn't work for me:

davidm@REDACTED:~$ erl
Erlang (BEAM) emulator version 5.4.9 [64-bit] [source] [threads:0]

Eshell V5.4.9  (abort with ^G)
1> {XmlFull,_} = xmerl_scan:string("<text>Hello</text>").
{{xmlElement,text,
            text,
            [],
            {xmlNamespace,[],[]},
            [],
            1,
            [],
            [{xmlText,[{text,1}],1,[],"Hello",text}],
            [],
            "/home/davidm",
            undeclared},
 []}
2> [XmlText] = xmerl_xpath:string("/text/text()", XmlFull).

=ERROR REPORT==== 5-Aug-2007::22:48:45 ===
Error in process <0.31.0> with exit value: {{badmatch,[]},[{erl_eval,expr,3}]}

** exited: {{badmatch,[]},[{erl_eval,expr,3}]} **
3>

Any thoughts?

Regards

Dave M.

On 05/08/07, Caoyuan <dcaoyuan@REDACTED> wrote:
> > [XmlText] = xmerl_xpath:string("/text/text()", XmlFull).
> [{xmlText,[{text,1}],1,[],"Hello",text}]
> > element(5, XmlText).
> "Hello"
>
>
> On 8/5/07, David Mitchell <monch1962@REDACTED> wrote:
> > Hello group,
> >
> > I'm having trouble getting my head around xmerl_xpath - I've gone
> > through a bunch of Google searches, but can't find the "Simple guide
> > to xmerl_xpath" I'm looking for ;->
> >
> > I've reduced my problem to 3 lines of code:
> >
> > 15> {XmlFull, _} = xmerl_scan:string("<text>Hello</text>").
> > {{xmlElement,text,
> >              text,
> >              [],
> >              {xmlNamespace,[],[]},
> >              [],
> >              1,
> >              [],
> >              [{xmlText,[{text,1}],1,[],"Hello",text}],
> >              [],
> >              "/home/davidm",
> >              undeclared},
> >  []}
> >
> > 16> xmerl:export([XmlFull], xmerl_xml).
> > ["<?xml version=\"1.0\"?>",[[["<","text",">"],["Hello"],["</","text",">"]]]]
> >
> > 17> xmerl_xpath:string("//text/*", XmlFull).
> > []
> >
> >
> > Line 16 seems to confirm that XmlFull contains my XML string.
> > However, I'd expect line 17 to give me something like "Hello" or
> > ["Hello"], yet it returns an empty list.
> >
> > Could someone please point out the (no doubt very simple) mistake I've
> > made?  Also, if a "Simple guide to xmerl_xpath" exists somewhere,
> > could someone please point me towards it?
> >
> > Thanks in advance
> >
> > Dave M.
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
>
> --
> - Caoyuan
>



More information about the erlang-questions mailing list