1
2
3
4
5
6
7
<result>
<target type="ziel">
<tag1>123</tag1>
<tag2>123</tag2>
...
</target>
</result>
1 2 3 4
my $twig = new Xml::Twig(twig_handlers => { "/result/target/tag\d" => \&meine_parse_funktion, });
1 2 3 4
my $twig = new Xml::Twig(twig_handlers => { "/result/target/tag[1-3]" => \&meine_parse_funktion, });
Twig DokuThis argument consists of a hash { expression = \&handler}> where expression is a an XPath-like expression (+ some others).
XPath expressions are limited to using the child and descendant axis (indeed you can't specify an axis), and predicates cannot be nested. You can use the string, or string(<tag>) function (except in twig_roots triggers).
Additionally you can use regexps (/ delimited) to match attribute and string values.
2011-04-27T13:03:33 pqschreib mal '/result/target/tag\d' (also single statt double quotes). sonst versucht perl das "\d" sofort zu interpretieren, genauso wie \n oder \t z.b.