Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by mirod (Canon)
on Apr 20, 2012 at 12:29 UTC ( #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>


Comment on Re: Using Perl XML::SAX to modify XML documents
Download Code
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
Node Status?
node history
Node Type: note [id://966187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2015-07-02 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (30 votes), past polls