PHP Read page file problems

Source: Internet
Author: User
I want to read some data from a webpage, the URL is: http://www.xjflcp.com/servlet/sscflash?type=full&rand=2266

My code is like this:
$url = "http://www.xjflcp.com/servlet/sscflash?type=full&rand=2266"; $doc = new DOMDocument (); $doc->load ($url ); Read XML file//$datas = $doc->savexml ();//$lst = $doc->getelementsbytagname (' history1 ');//$t 1 = $lst->item (0)- >getelementsbytagname ("Draw")->item (0)->nodevalue; An array of objects that get the label of name//$t 1 = substr ($t 1,2,6). " 0 ". substr ($t 1,-2);//$t 2 = $lst->item (0)->getelementsbytagname (" Prize_number ")->item (0)->nodevalue; An array of objects that get the label of name//$t 2 = str_replace ("|", ",", $t 2); $lst = $doc->getelementsbytagname (' Row ');//For    ($i =0; $i < $lst->length; $i + +) {for ($i =0; $i <2; $i + +) {$iframe = $lst->item ($i); $t 1= $iframe->attributes->getnameditem (' Draw ')- >value; $t 2= $iframe->attributes->getnameditem (' Prize_number ')->value;


Want to get the second row
 
  
  
   
    
   2014082856
  
   
  
   
    
   1|4|0|9|5
  
   
  
   
    
   57446
  
   
  
   
    
   at
  
    >
 
  

Draw, Prize_number How should I change


Reply to discussion (solution)

$url = "http://www.xjflcp.com/servlet/sscflash?type=full&rand=2266"; $doc = new DOMDocument (); $doc->load ($url ), $recent _draws= $doc->getelementsbytagname ("Recent_draw"), $recent _draw= $recent _draws->item (0); $draw = Getnodeval ($recent _draw, "Draw"), $prize _number=getnodeval ($recent _draw, "Prize_number"); Echo $draw. '
' Echo $prize _number. '
'; function Getnodeval (& $myNode, $tagName) {return $myNode->getelementsbytagname ($tagName)->item (0) NodeValue;} /*20140828654|6|9|6|4*/
  • 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.