Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Tomcat context.xml parsing using XML::SImple

by jagadish1982 (Initiate)
on Nov 21, 2012 at 10:12 UTC ( #1004889=perlquestion: print w/ replies, xml ) Need Help??
jagadish1982 has asked for the wisdom of the Perl Monks concerning the following question:

Hi , Is there any way to remove a <Resource> element in tomcat context.xml file using XML::Simple. Thanks In advance for all the suggestions

Comment on Tomcat context.xml parsing using XML::SImple
Re: Tomcat context.xml parsing using XML::SImple
by Anonymous Monk on Nov 21, 2012 at 10:13 UTC
    No.
Re: Tomcat context.xml parsing using XML::SImple
by tobyink (Abbot) on Nov 21, 2012 at 10:28 UTC

    For any XML work where any of the following is true, XML::Simple is not your friend:

    • The order of elements is important.
    • The distinction between an element and an attribute is important.
    • You want to preserve comments.
    • You want to preserve whitespace.

    Use something like XML::LibXML instead.

    TL;DR: No.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Is there any good option to parse the tomcat context.xml files using perl .

        Use something like XML::LibXML instead.

        or even XSH2

Re: Tomcat context.xml parsing using XML::SImple
by Jenda (Abbot) on Nov 22, 2012 at 15:26 UTC
    use XML::Rules; my $parser = XML::Rules->new( style => 'filter', rules => { Resource => sub {}, } ); $parser->filter(\*DATA); __DATA__ <root> <b>dgfdg</b> <Resource>delete</Resource> <c>ffgdfg<Resource>ddd</Resource>ddddd</c> </root>

    See the docs if you want to filter a file and not a filehandle and write the result elsewhere than STDOUT.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1004889]
Approved by tobyink
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2014-08-01 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls