求大神解答一个关于foreach的问题
有一个XML,例如:
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?xml version="1.0" encoding="utf-8"?> <top> <middle> <bottom> <value1>8000</value1> <value2>8001</value2> <value3>8002</value3> </bottom> </middle> </top>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> $mid=$xml2->getElementsByTagName("middle")->item(0); foreach($mid->childNodes as $v1){ echo $v1->tagName; foreach($v1->childNodes as $c2){ echo $c2->tagName; echo $c2->nodeValue; } }