Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: XML::Twig - how can I test for an attribute when the attribute value is 0?

by Khen1950fx (Canon)
on Aug 30, 2012 at 02:21 UTC ( [id://990619]=note: print w/replies, xml ) Need Help??


in reply to XML::Twig - how can I test for an attribute when the attribute value is 0?

mirod did a post showing how to handle attributes. Re: retrieving attribute text with xml::twig. Here's his example:
#!/usr/bin/perl -l BEGIN { $| = 1; $^W = 1; } use strict; use autodie; use warnings; use XML::Twig; my $elt =XML::Twig->new( start_tag_handlers => { _all_ => sub { print join( ' - ' => values %{ $_->atts } ); } })->parse( \*DATA ); __DATA__ <doc> <elt att="not rare">fq0</elt> <elt att="not rare">fq1</elt> <elt att="rare">fq2</elt> </doc>
  • Comment on Re: XML::Twig - how can I test for an attribute when the attribute value is 0?
  • Download Code

Replies are listed 'Best First'.
Re^2: XML::Twig - how can I test for an attribute when the attribute value is 0?
by Anonymous Monk on Aug 30, 2012 at 03:10 UTC

    Once again you did not read/understand the question being asked, which philiprbrenan and kcott already answered

      Did you read mirod's post?

        Did you read mirod's post?

        What difference would that make?

        Did you read mirod's post?

        In what way do you think it answers the OPs question?

        philiprbrenan showed one answer (using ->att) 10 min after the OP asked

        kcott showed the other answer (using ->atts) the next day

        2 hours later Khen1950fx digs up a post by mirod copy/pastes the code -- even though it doesn't answer the OPs question, same as mirod's entire post

        Sure atts could be part of the answer, but it isn't.

        The OP already knew how to deal with attributes (att), and hey, kcott already showed how to use atts to solve the OPs problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://990619]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found