Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by kcott (Canon)
on Aug 30, 2012 at 00:38 UTC ( #990607=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?

I'm not an XML::Twig user; however, its documentation has:

atts
Return a hash ref containing the element attributes

So, you should be able to determine if fq is present with exists:

exists $label->atts()->{fq}

This will return true even if the value is undef.

Assuming the attribute exists, you may also want to check the value with defined and possibly even length (to check for a zero-length string) before checking for truth or specific values.

-- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990607]
help
Chatterbox?
[stevieb]: Hey ww. Just laying down watching a hockey game, running my auto build distribution that automates Strawberry installs to figure out which ones had csum changes so berrybrew doesn't barf on those ones
[stevieb]: ...and closing some issues on some of my other dists

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2017-03-30 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (353 votes). Check out past polls.