xmerl_xpath lists reversed?
Mikael Karlsson
mikael.karlsson@REDACTED
Fri Sep 13 10:27:17 CEST 2002
Hi,
I am trying to extract xmlElement nodes from a document using
xmerl_xpath. The nodes seem to show up in reversed order.
The example below gives me the last section title, while I expected
the first. Have I missed something in the interpretation of xmerl_xpath?
Thanks
Mikael
Code snippet:
{B,_}=xmerl_scan:file(A#arg.docroot ++ "/testdir/test1.xml",[{fetch_fun,
fun(DTDSpec,S) -> {ok,S} end}]),
D = xmerl_xpath:string("child::node()/title[position() = 1]",B),
io:fwrite("~p~n",[D]),
F = sdocbook2xhtml:changetitle(B),
C = xmerl:export(F,sdocbook2xhtml),
{content,"text/html",C}.
Document:
<?xml version="1.0" encoding="iso-8859-1"?>
<article lang="en" >
<articleinfo>
......bla bla....
</articleinfo>
<section>
<title>Section 1</title>
<para>Para 1 in section 1</para>
</section>
... lots of sections...
<section>
<title>Section 6, the last section</title>
<para>This is the first paragraph in the last section. </para>
</section>
</article>
io:fwrite gives:
[{xmlElement,title,
[{section,14},{article,1}],
2,
[],
[{xmlText,[{title,2},{section,14},{article,1}],
1,
[],
"Section 6, the last section"}],
[],
title,
[],
{xmlNamespace,[],[]}}]
More information about the erlang-questions
mailing list