Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by kcott (Archbishop)
on Aug 30, 2012 at 00:38 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://990607]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found