Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by kcott (Abbot)
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


Comment on Re: XML::Twig - how can I test for an attribute when the attribute value is 0?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-07-11 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (227 votes), past polls