in reply to Re: XPath crashing
in thread XPath crashing

Thanks for the steers, I have been browsing the Twig and Rules documentation today. I will download the packs this evening and experiment with them.

The xml is very simple...

<users> <user> 5-6 simple key's here <teamid>100</teamid> </user> </users>
... there are many thousands of user tags, but I am only interested in the 100 - 150 records with the correct teamid.

Replies are listed 'Best First'.
Re^3: XPath crashing
by Jenda (Abbot) on Feb 05, 2007 at 22:59 UTC

    It's a shame the teamid is a subtag and not an attribute, you will be unable to use the "start" rules. Which will make the script a bit slower, but not more memory hungry. In this case I think

    my $parser = XML::Rules->new( rules => [ _default => 'content', user => sub { return unless $_[1]->{teamid} = $_[4]->{parameters}{teamid}; delete $_[1]->{_content}; # delete the textual context (whitespace) return '@user' => $_[1]; }, users => 'pass no content', ] ); my $users = $parser->parsefile( $the_xml_file, {teamid => 100};
    should give you the data for the right users only.