Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Using Perl XML::SAX to modify XML documents

by mirod (Canon)
on Apr 20, 2012 at 12:29 UTC ( [id://966187]=note: print w/replies, xml ) Need Help??


in reply to Using Perl XML::SAX to modify XML documents

Also cross-posted from SO, an efficient solution with XML::Twig:

#!/usr/bin/perl use strict; use warnings; use XML::Twig; XML::Twig->new( twig_roots => { span => sub { $_->set_tag( 'naps +')->flush; }, expandable => sub { XML::Twig::Elt->ne +w( expanded => 'this is an expanded element')->print; }, }, twig_print_outside_roots => 1, ) ->parsefile( \*DATA); __DATA__ <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket +.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> <body> <wicket:panel> <form wicket:id="mvpForm"> <span>Edit Information: </span> <input type="checkbox" wicket:id="editForm"/> <span>Name: </span> <span wicket:id="name"></span> <input type="text" wicket:id="nameEdit"/> <span>Last Name: </span> <span wicket:id="lastName"></span> <input type="text" wicket:id="lastNameEdit"/> <span>DOB: </span> <span wicket:id="dob"></span> <input type="text" wicket:id="dobEdit"/> <span>Occupation: </span> <span wicket:id="occupation"></span> <input type="text" wicket:id="occupationEdit"/> <span>Gender: </span> <span wicket:id="gender"></span> <span wicket:id="genderEdit"/> <input type="submit" wicket:id="submit"/> </form> <xmltag> <expandable/> </xmltag> </wicket:panel> </body> </html>

Replies are listed 'Best First'.
Re^2: Using Perl XML::SAX to modify XML documents
by dryajov (Initiate) on Apr 20, 2012 at 19:30 UTC
    Thanks, I've accepted your responce on stackoverflow. This seems the most straigh forward way of working with XML for the example I provided.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-25 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found