php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55285 XMLReader::getAttribute/No/Ns methods inconsistency
Submitted: 2011-07-26 12:18 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: evoloshchuk at gmail dot com Assigned:
Status: Closed Package: XML Reader
PHP Version: 5.3.6 OS: Mac OS X 10.6.3
Private report: No CVE-ID: None
 [2011-07-26 12:18 UTC] evoloshchuk at gmail dot com
Description:
------------
There are three methods available to retrieve an attribute - getAttribute, getAttributeNo, getAttributeNs.
It seems to be natural to expect the similar kind of behavior from them in case when no attribute by given parameters is found.
Which is not the case - first one returns NULL, the rest - string(0) "".

Test script:
---------------
<?php
  $reader = new XmlReader();
  $reader->xml('<?xml version="1.0" encoding="UTF-8"?><a y="" z="1"></a>');
  $reader->read();
  var_dump($reader->getAttribute('x'));
  var_dump($reader->getAttributeNs('x', 'http://example.com'));
  var_dump($reader->getAttributeNo(2));
?>

Expected result:
----------------
NULL
NULL
NULL

Actual result:
--------------
NULL
string(0) ""
string(0) ""

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-03 13:23 UTC] mike@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c7b1d76eb9d09b0331272143e44e5024468b0fea
Log: fix bug #55285 XMLReader::getAttribute/No/Ns methods inconsistency
 [2013-10-03 13:23 UTC] mike@php.net
-Status: Open +Status: Closed
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c7b1d76eb9d09b0331272143e44e5024468b0fea
Log: fix bug #55285 XMLReader::getAttribute/No/Ns methods inconsistency
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 12 00:01:40 2024 UTC