php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30617 I can't get attributes of nodes, when I use XML document with namespace definit
Submitted: 2004-10-29 21:55 UTC Modified: 2004-10-30 11:54 UTC
From: sveta at microbecal dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5CVS-2004-10-29 (dev) OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
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:
36 - 13 = ?
Subscribe to this entry?

 
 [2004-10-29 21:55 UTC] sveta at microbecal dot com
Description:
------------
When I use XML document with namespace definitions, I can't get attributes of nodes

Reproduce code:
---------------
$xml_file = 'test.xml';
$xml = simplexml_load_file($xml_file);
foreach($xml->Worksheet->attributes() as $a => $b) {
    echo $a,'="',$b,"\"\n";
}

test.xml:
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <Worksheet ss:Name="English">
 </Worksheet>
</Workbook>

Expected result:
----------------
Name="English"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-29 21:58 UTC] sveta at microbecal dot com
Real result:
nothing :)
 [2004-10-30 00:56 UTC] derick@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

You need to take care of the namespaces.
 [2004-10-30 11:54 UTC] sveta at microbecal dot com
$xml_file = 'test.xml';
$xml = simplexml_load_file($xml_file);
foreach($xml->Worksheet->attributes('urn:schemas-microsoft-com:office:spreadsheet') as $a => $b) {
    echo $a,'="',$b,"\"\n";
}

Thank you for pointing me to my mistakes
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC