Could you please give me a question about foreach?

Source: Internet
Author: User
Please give me a question about foreach, such as XMLcode & lt ;? Xmlversion & quot; 1.0 & quot; encoding & quot; UTF-8 & quot ;? & Gt; & lt; top & gt; & lt; middle & gt; & lt; bottom & gt; & lt; valu
There is an XML file, for example:
XML code
  
  
      
           
                
     
      8000
                 
     
      8001
                 
     
      8002
             
        
   
  

I want to find the middle first, and the print is similar:
Bottom:
Value1: 8000
Value2: 8001
Value3: 8002
The DOM parsing code is as follows:
PHP code
  $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;        }    }

It can be printed, but a warning will appear. in The foreach line, it is a parameter problem. how can this problem be solved?

------ Solution --------------------
The same is true.

8000
8001
8002

Four line breaks, not output four teams?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.