I just want to analyze the xml element of interest (for example, see below: a class element with a name is equal to mathematics), and I want to stop as soon as the first element that hits this condition is parsed. (since there is only one class whose name is mathematics, there is no need to continue as soon as the element is already found).
However, if I implement it as follows, the code continues to read the entire file after it finds the element that interests me (the xml file is very long, so it takes a lot of time). my question is how to stop it when parsing the first element of a class named = math?
my $twig = new XML::Twig(TwigRoots => {"class[\@name='math']" => \&class}); $twig->parsefile( shift @ARGV );
In addition, I also want to remove this class from the xml file (not only from memory) after parsing it, so the next time when parsing the class with other names, the class element will not be parsed. Can this be done?
source share