|
 |
|
สอบถาม xml+javascript +url จากที่อื่น ผมจะนำ xml จาก url ที่อื่นมาแสดงครับ แต่ไม่ได้สักที |
|
 |
|
|
 |
 |
|
in-my-server.php โค้ด
<?php echo file_get_contents('http://www.example.com/test.xml'); ?>
เรียกผ่านไฟล์ in-my-server.php แทนครับ
|
 |
 |
 |
 |
Date :
2009-12-04 20:08:06 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$doc = new DOMDocument('1.0', 'window-874');
$doc->load('http://www.manager.co.th/RSS/Home/Breakingnews.xml');
$root = $doc->getElementsByTagName('channel');
foreach($root as $node)
{
$item = $node->getElementsByTagName('item');
foreach($item as $nodeitems)
{
$title = $nodeitems->getElementsByTagName('title');
foreach($title as $titles)
{
echo '<br><b>'.$titles->nodeValue.'</b><br>';
}
$link = $nodeitems->getElementsByTagName('link');
foreach($link as $links)
{
echo '<a href='.$links->nodeValue.'>'.$links->nodeValue.'</a><br>';
}
$desc = $nodeitems->getElementsByTagName('description');
foreach($desc as $descs)
{
echo $descs->nodeValue.'<br>';
}
$pubdate = $nodeitems->getElementsByTagName('pubDate');
foreach($pubdate as $pubdates)
{
echo $pubdates->nodeValue.'<p><hr>';
}
}
}
แบบแมนนวล ครับ
|
 |
 |
 |
 |
Date :
2009-12-04 23:01:24 |
By :
extenser |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมหามาแล้วครับจนไปเจอที่หนึ่ง เขาบอกว่าทำไม่ได้ถ้า url ไม่ผ่านการแปลงไฟล์จาก server มาก่อน เซ้าเลย T_T
ขอบคุณพี่หนุ่มกับคุณ extenser น่ะครับที่มาตอบ ตอนนี้ผมก็ใช้ php ทั้งหมดเลยครับแบบเดียวกับโค้ดของ extenser ครับ
|
 |
 |
 |
 |
Date :
2009-12-05 02:17:11 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|