Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928483]
[usemodperl]: perlmonks used to be a safe space for perl coders, now it's like having an annoying girlfriend...
[marto]: I had a feeling I'd regret looking up the definition of 'soyboy'
[Veltro]: usemodperl Maybe it is the way you talk? 'Soy boys', 'old ladies' and what is even a tgimer...
usemodperl is venting, duh?
[usemodperl]: that was a typos, dumbass
[marto]: usemodperl I guess that depends on what you mean by a safe space, since many people seem to have the impression a safe space allows them to do/say whatever they feel like, without question or critque
[marto]: 'typos'->'typo'
[usemodperl]: it's like you guys are retarded or something, no sense of humor? autism?
[usemodperl]: take things too literally, nothing is funny, everyhting must be perfect, or else, SCOLD SCOLD SCOLD, haha
[Veltro]: usemodperl I think you are offensive right now.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2018-06-24 15:46 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.