Witam,
Jakim najlepszym sposobem będzie wyciągniecie danych z XML a dokładnie z konkretnego wiersza??
Mój plik XML wygląda tak...
<?php
require_once "../maincore.php";
if ($settings['hide_userprofiles'] && !iMEMBER) { redirect(BASEDIR."login.php"); }
if (isset($_GET['url']) && isnum
($_GET['url'])) { $result = dbquery("SELECT * FROM ".$db_prefix."lonsters WHERE lonsters_id='".$_GET['url']."' LIMIT 1");
}
if (dbrows($result)) { $video_data = dbarray($result); } else { redirect("index.php"); }
header ("Content-Type:text/xml"); ?>
$url = $linkers_data['lonsters_url'];
echo "<xml version=\"1.0\" encoding=\"utf-8\">";
echo "<channel>";
echo "<link>http://www.youtube.com/v/$url</link>";
echo "</channel>";
echo "</xml>";
?>
I przykładowo link do XML wygląda tak:Adres:
http://www.yousite.pl/movie/y.php?url=11Zastosowałem do wyciągnięcia taką funkcje:
<?php
$reader = new XMLReader();
$file = "http://www.yousite.pl/movie/y.php?url=11";
$reader->open($file);
$count=0;
while($reader->read())
{
if($reader->nodeType == XMLReader::ELEMENT)
{
$name = $reader->name;
if ($reader->name == 'link')
{
$notes[$count] = array(); }
}
if($reader->nodeType == XMLReader::TEXT || $reader->nodeType == XMLReader::CDATA)
{
$notes[$count][$name] = trim($reader->value); }
if($reader->nodeType == XMLReader::END_ELEMENT)
{
if ($reader->name == 'link')
{
$count++;
}
}
}
?>
Tylko nie chce aby mi wyświetlało całe drzewo lecz konkretny atrybut, w tym wypadku zawartość węzła
<link>
Ten post edytował Rafee 1.03.2011, 12:17:04