Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: XML Search and Replace

by Desdinova (Friar)
on Jun 11, 2002 at 17:26 UTC ( [id://173578]=note: print w/replies, xml ) Need Help??


in reply to XML Search and Replace

Everything I have done with XML has been with XML::Twig Of course there has been very little.
Recently I faced a problem kind of like this. I had a XML file that had fields that need to be updated each day the way I did it was to create a handler for element that needed to be updated
my $twig = XML::Twig->new(twig_handlers => {MONTH => \&upd_month, DAY => \&upd_day, YEAR => \&upd_year }, PrettyPrint =>'indented', ); $twig->parsefile(XML_FILE);

Then in the handlers i used the set_text method to replace the value to what I needed
sub upd_month{ my( $t, $post)= @_; $post->set_text("$expire{month}"); } sub upd_day{ my( $t, $post)= @_; $post->set_text("$expire{day}"); } sub upd_year{ my( $t, $post)= @_; $post->set_text("$expire{year}"); }

I dont if this would work well for your situation but it fit the niche I had to fill so I thought I would pass it along.
Desdinova

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://173578]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found