Randal L. Schwartz wrote:
""Beginner"" == "Beginner"  <[EMAIL PROTECTED]> writes:

"Beginner"> I have been trying to use XML::Simple and I had a go with XML::Smart "Beginner"> but I haven't been able to get the results I want.

I'd use XML::LibXML, with an XPath expression, as follows.  I'm demoing by
deleting the one that starts "BJPU", but replace that with your "0000" and
you're all set.

Note that the XPATH says "find any address node that contains a code node
whose text begins with BJPU".  And those are the ones we want to delete.

    #!/usr/bin/env perl
    use strict;

    use XML::LibXML;
    my $parser = XML::LibXML->new;
    my $doc = $parser->parse_fh(\*DATA);

    my @bad = $doc->findnodes(q{//address[.//code[starts-with(., "BJPU")]]});

my @bad = $doc->findnodes(q{//address[starts-with(code, "BJPU")]});

Rob


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to