Anonymous | Login | Signup for a new account | 11-21-2024 21:50 PST |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | |||||||
0003064 | [Quercus] | major | always | 11-11-08 04:17 | 11-11-08 04:17 | |||||||
Reporter | alexbu | View Status | public | |||||||||
Assigned To | ||||||||||||
Priority | normal | Resolution | open | |||||||||
Status | new | Product Version | 3.2.1 | |||||||||
Summary | 0003064: DOMNamedNodeMap cannot be used in foreach statement | |||||||||||
Description |
It's not possible to use 'foreach' statement to iterate over an instance of DOMNamedNodeMap, returnted by $domElement->attributes, where $domElement is DOMElement Though, there is no problem with iterating over DOMNodeList, returned by $domElement->childNodes |
|||||||||||
Additional Information |
<?php $test_str = "<?xml version='1.0' encoding='utf-8'?> <root> <first attr1='value1' attrx='attrx'/> <second attr2='value2'/> <third/> </root>"; function node_value($node) { foreach ($node->childNodes as $item) { if ($item instanceof DOMText) continue; echo 'node: ' . $item->nodeName . "\n"; if ($item->hasAttributes()) { foreach($item->attributes as $attr) { echo 'attribute: ' . $attr->nodeName . ' with value: ' . $attr->nodeValue . "\n"; } } if ($item->hasChildNodes()) node_value($item); } } $doc=new DOMDocument(); if($doc->loadXML($test_str)===false) return false; echo 'root:' . $doc->documentElement->nodeName . "\n"; node_value($doc->documentElement); |
|||||||||||
Attached Files | ||||||||||||
|
There are no notes attached to this issue. |
Issue History | |||
Date Modified | Username | Field | Change |
11-11-08 04:17 | alexbu | New Issue | |
11-11-08 04:18 | alexbu | Issue Monitored: alexbu |
Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
27 total queries executed. 24 unique queries executed. |