Mantis - Quercus
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
3064 | major | always | 11-11-08 04:17 | 11-11-08 04:17 | |
|
|||||
Reporter: | alexbu | Platform: | |||
Assigned To: | OS: | ||||
Priority: | normal | OS Version: | |||
Status: | new | Product Version: | 3.2.1 | ||
Product Build: | Resolution: | open | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | |||
|
|||||
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 |
||||
Steps To Reproduce: | |||||
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); |
||||
Relationships | |||||
Attached Files: |
There are no notes attached to this issue. |