-
PHP
(
https://www.ircforumlari.net/php/)
- -
DomXML kullanımı
(
https://www.ircforumlari.net/php/629362-domxml-kullanimi.html)
DomXML kullanımı PHP- Kodu: $html = '<html>
<head>
<title>links</title>
</head>
<body>
<a href="link1.htm" title="Link title 1" target="_blank">Link #1</a><br/>
<a href="link2.htm" title="Link title 2" target="_blank">Link #2</a><br/>
<a href="link3.htm" title="Link title 3" target="_blank">Link #3</a><br/>
</body>
</html>';
// check if DomXML is available:
if (!function_exists('DomDocument')){
die('DomXML extension is not available :-(');
}
print '<pre>';
// create new DOM object:
$dom = new DomDocument();
// load HTML code:
$dom->loadHtml($html);
// get tags by tagname (all <a> tags / links):
$tags = $dom->getElementsByTagName('a');
// loop trough all links:
foreach ($tags as $a){
print '<b>' . $a->nodeValue . '</b><br/>';
// does this tag have attributes:
if ($a->hasAttributes()){
// loop trough all attributes:
foreach ($a->attributes as $attribute){
print '- ' . $attribute->name . ': ' . $attribute->value;
print "<br/>";
}
}
print "<hr/>";
}
print '</pre>';
|
Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 16:33. | |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2025 IRCForumlari.Net Sparhawk