[erlang-questions] xmerl_xpath difficulties

David Mitchell <>
Sun Aug 5 10:53:40 CEST 2007


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.



More information about the erlang-questions mailing list