php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66684 Issue with recurring elements and attributes
Submitted: 2014-02-10 12:31 UTC Modified: 2015-09-08 16:28 UTC
From: rasmus at 3kings dot dk Assigned: cmb (profile)
Status: Duplicate Package: SimpleXML related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2014-02-10 12:31 UTC] rasmus at 3kings dot dk
Description:
------------
I have an XML file <http://www.mercurymarine.dk/public/export/XMLalleprodukter.xml> with a recurrence of the element <specification>. When loaded in SimpleXML i get the following structure (note that the top level has attributes defined whereas <specification> does not).

---
From manual page: http://www.php.net/simplexmlelement.attributes
---


Test script:
---------------
print_r(SimpleXMLElement(file_get_contents("http://www.mercurymarine.dk/public/export/XMLalleprodukter.xml")));

Expected result:
----------------
... something that allows me to read the attributes of the <specification> elements.

Actual result:
--------------
SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [type] => Påhængsmotorer
            [id] => 17827
            [produkttype] => nyt
            [forhandlertype] => importør
        )

    [title] => Mercury 30MLH 2-takt
    [dealer_name] => SimpleXMLElement Object
        (
        )

    [dealer_address] => Sundvej 12 F
    [dealer_postalcode] => 4600
    [dealer_city] => Køge
    [dealer_email] => mads@jdas.dk
    [dealer_phone] => 4049 2920
    [dealer_webadresse] => www.mercurymarine.dk
    [description] => Sælges kun til erhvervsbrug. MED/SOLAS godkendt. Download godkendelses certifikat fra højre spalte.
    [price] => 27120.00
    [url] => www.mercurymarine.dk/produkter/motorer/solasogmedgodkendtepaahaengsmotorer/mercurymedsolag2-taktmotorer/me-30mlh.html
    [picture] => Array
        (
            [0] => http://www.mercurymarine.dk/public/billeder/produkter-jpg/Motorer/Mercury/ME_2takt/ME_2takt30cc429/Me$2s$F250-2_5$30cc429.jpg
            [1] => http://www.mercurymarine.dk/gfx/imager/produkter-jpg/Motorer/Mercury/ME_2takt/ME_2takt30cc429/Me$2s$F250-2_5$30cc429.jpg?s=product
        )

    [specification] => Array
        (
            [0] => Påhængsmotor
            [1] => 1,92:1
            [2] => 508mm
            [3] => 30.00
            [4] => 6
            [5] => F-F-B
            [6] => 2
            [7] => 22,1
            [8] => 429
            [9] => 51
            [10] => 6
            [11] => Manuel
            [12] => 4800-5500
            [13] => Styrehåndtag
            [14] => 1 karburator
            [15] => 2-takt
            [16] => for fejl og ændringer i specifikationerne
        )

)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-08 16:28 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-09-08 16:28 UTC] cmb@php.net
Actually, this is a duplicate of bug #44973. To see the attributes
of the <specification> element, you have to iterate over
::attributes(). print_r() won't show them.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 16 09:01:28 2019 UTC