Skip to content

attribute() returns null, when value is 0 #2

@dkarvounaris

Description

@dkarvounaris

I've been using ACFBentveld/XML which is now archived, but after checking a little, it seems that these packages are identical, so I suppose this error occurs here too (the source of the class where the bug may resonate from is identical).

I have a xml file, which has lines like:

<Category ID="9158" LowPic="http://images.icecat.biz/img/low_pic/9158-2307.jpg" Score="0" Searchable="0" ThumbPic="http://images.icecat.biz/thumbs/CAT9158.jpg" UNCATID="49141596" Visible="0" Updated="2021-08-09 08:56:01">
   ...
</Category>

In my code I'm using $element->attribute('Searchable') (where $element represents a <Category>).
When the value is 1, I receive "1" as value. But when the value is 0, it returns null, when it should return "0". The same happens also with the "Visible" attribute.

I temporarily fixed the results in my code by using $element->attribute('Searchable', 0), but that doesn't fix the bug in the package. While $element->hasAttribute('Searchable") returns the correct result, attribute() returns null as if the attribute wouldn't be there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions