Thread

Posted on Wed Jul 19 18:59:22 2006 by szabgab
specify path using bot tag names and attributes (using v3.25)
I would like to write something like this:
my $twig=XML::Twig->new( twig_handlers => { '/tag1[@att1="morgo"]/tag2[@att2="korgo"]' => \&process_key, }, );

that is, to define a path using both tag names and attribute values on several levels. (Sometimes 5-10 levels!)

I played a bit with Twig but as I can see providing attribute definition can only be done with one tag.

'tag2[@att2="korgo"]' => \&process_key,

Is this the situation or am I missing something?
How can I define such a detailed path?

Direct Responses: 2667 | 2801 | Write a response
Posted on Fri Jul 21 23:15:20 2006 by mirod in response to 2652
Re: specify path using bot tag names and attributes (using v3.25)

Indeed, you cannot write a handler trigger that mixes attribute tests and a path.

It would not be that hard to add this, and this request has come up quite a few times, so I guess I'll be working on it shortly.

BTW I have long delayed work on this because if I want to do this properly I would need to write a complete streaming XPath parser like STX, which I have been postponing successfully for a number of years now ;--(

--
mirod

Write a response
Posted on Mon Aug 21 11:20:09 2006 by mirod in response to 2652
Re: specify path using bot tag names and attributes (using v3.25)

If you want to have a look at the latest development version at http://xmltwig.com/xmltwig/ , it should allow you to write complex handlers like the one you want.

--
mirod
Write a response