php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44472 SimpleXMLElement() drops nodes
Submitted: 2008-03-18 19:17 UTC Modified: 2008-03-21 10:58 UTC
From: jsafley at gmu dot edu Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 + 32 = ?
Subscribe to this entry?

 
 [2008-03-18 19:17 UTC] jsafley at gmu dot edu
Description:
------------
new SimpleXMLElement() drops namespaced nodes.

Reproduce code:
---------------
$xmlstr = <<<XML
<OAI-PMH>
  <ListRecords>
    <record>
      <metadata>
        <oai_dc:dc 
          xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" 
          xmlns:dc="http://purl.org/dc/elements/1.1/">
          <dc:title>A comparative study</dc:title>
          <dc:creator>Talabi, A.O.</dc:creator>
          <dc:publisher>African Journal</dc:publisher>
          <dc:date>1970-01-01</dc:date>
        </oai_dc:dc>
      </metadata>
    </record>
  </ListRecords>
</OAI-PMH>
XML;
$xml = new SimpleXMLElement($xmlstr);
print_r($xml);

Expected result:
----------------
SimpleXMLElement Object
(
  [ListRecords] => SimpleXMLElement Object (
    [record] => SimpleXMLElement Object (
      [metadata] => SimpleXMLElement Object(
        [dc] => SimpleXMLElement Object (
          [title] => SimpleXMLElement Object (
           A comparative study
          )
          [creator] => SimpleXMLElement Object (
            Talabi, A.O.
          )
          [publisher] => SimpleXMLElement Object (
            African Journal
          )
          [date] => SimpleXMLElement Object (
            1970-01-01
          )
        )
      )
    )
  )
)

Actual result:
--------------
SimpleXMLElement Object
(
  [ListRecords] => SimpleXMLElement Object (
    [record] => SimpleXMLElement Object (
      [metadata] => SimpleXMLElement Object(
      )
    )
  )
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-19 00:18 UTC] felipe@php.net
This output seems expected, see this article:
http://devzone.zend.com/node/view/id/688#Heading3
 [2008-03-21 10:58 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

SimpleXML works within namespaced scopes. The default being the scope of 
no and default namespace.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 21:01:27 2024 UTC