Maxim has asked for the wisdom of the Perl Monks concerning the following question:
use XML::LibXML; use CGI ':standard'; use warnings; use strict; #Variables my $newval; my $categor = 'Coffee'; my $oldval; my $prod = '801.55.01'; my $cats; my $success; print header; if ($categor eq 'Coffee') { $cats = 'C:\Program Files\Apache Group\Apache2\htdocs\lega +stronome\XML\admin\coffee.xml'; } else { print "Sorry the category that you wanted to edited doesn' +t exist. Please contact your administrator. \n Thanks"; exit 1; } my $cat = $cats; my $parser = XML::LibXML->new(); my $d = $parser->parse_file(join "", $cat); for my $dead ($d->findnodes(q{/category/subcategory/product[product_id + = $prod]})) { $dead->unbindNode; $success = 1; } if ($success eq 1) { print "<html><head></head>\n"; print "<body>\n"; print "<p>Test</p>\n"; print "<p><h1>Done for</h1></p>\n"; print "<br\>\n"; print "<br><br><a href=\'javascript:window.close();\'>Close this w +indow </a>\n"; #$d->toFile($cat); print $d->toString; print"<br><h3>All done!</h3>"; print "</body></html>\n"; exit 1; } else { print "<html><head></head>\n"; print "<body>\n"; print "<p>Fail!!</p>\n"; print "<br\>\n"; print "<br><br><a href=\'javascript:window.close();\'>Close this w +indow </a>\n"; print "</body></html>"; } __DATA__ <category name="Coffee"> <heading>150 years of know how at the service of a same strategy: Ta +ste</heading> <photo>images/bag_legal.jpg</photo> <subcategory name="Prestige"> <photo>images/prestige.jpg</photo> <product>Coffee <brand>Legal</brand> <channel>D</channel> <channel>A</channel> <conditionning unit="gr">250</conditionning> <description>Legal Prestige</description> <packaging_qty>12</packaging_qty> <product_id>800.55.01</product_id> <recipe>/recipes/coffee1.html</recipe> </product> <product>Coffee <brand>Legal</brand> <channel>D</channel> <channel>A</channel> <conditionning unit="gr">500</conditionning> <description>Legal Prestige Boite Arôme</description> <packaging_qty>6</packaging_qty> <product_id>801.55.01</product_id> </product> </subcategory> </category>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 1 object left on the stack
by CJXJ220 (Initiate) on Jan 10, 2019 at 14:31 UTC |