Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: How can I replace a line (tag) in an XML file?

by mirod (Canon)
on Sep 29, 2011 at 07:48 UTC ( #928483=note: print w/replies, xml ) Need Help??


in reply to Re: How can I replace a line (tag) in an XML file?
in thread How can I replace a line (tag) in an XML file?

You can even put the test on the content of id in the handler condition, and not in the sub:

twig_handlers => { 'student[string(id)="002"]' => sub { $_->first_child('gpa')->set_text('B'); } }

Note that if the id is in a variable, then quote delimiter collisions between Perl and XPath makes it a little more annoying. Luckily Perl allows us to use whatever character we want with qq{}:

twig_handlers => { qq{student[string(id)="$id"]} => sub { $_->first_child('gpa')->set_text('B'); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928483]
help
Chatterbox?
[Corion]: LanX: Yes, that's the main problem - you have lots (and lots) of workarounds in various places and stages of the processing, and to clean that mess up requires action across the complete codebase. And it's almost impossible to do it piece-by-piece
Corion is in a similar situation.#

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2017-01-16 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (150 votes). Check out past polls.