1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | $curl = curl_init(); $timeout = 5; $url = '가져올 xml 주소' ; curl_setopt( $curl , CURLOPT_URL, $url ); curl_setopt( $curl , CURLOPT_RETURNTRANSFER, 1); curl_setopt( $curl , CURLOPT_CONNECTTIMEOUT, $timeout ); $xml = curl_exec( $curl ); curl_close( $curl ); $doc = new DOMDocument(); $doc ->preserveWhiteSpace = false; $doc ->loadXML( $xml ); $xpath = new DOMXpath( $doc ); // Register the itunes namespace $items = $doc ->getElementsByTagName( 'item' ); foreach ( $items as $item ) { $title = $xpath ->query( 'title' , $item )->item(0)->nodeValue; $type = $xpath ->query( 'type' , $item )->item(0)->nodeValue; $author = $xpath ->query( 'itunes:author' , $item )->item(0)->nodeValue; $update = $xpath ->query( 'itunes:subtitle' , $item )->item(0)->nodeValue; $enclosure = $xpath ->query( 'enclosure' , $item )->item(0); $url = $enclosure ->attributes->getNamedItem( 'url' )->value; } |