Till death do us part
Axels New Music releases
Goth and Gore Gifts
Shop right now or else!
Sharp Stuff
Switchblades Icepicks and german knives
Sell your soul
Believeth in me an hath everlasting life

Search the script archive.

Enter a search term check the script type and click submit. To search for a general category for example to find all results for scripts working with text files or file manipulation enter file or curl. Same for directory, sql etc. Otherwise use specific terms.

Here is the script you requested.

scripts/dom-xml-scraper.txt: 1011 bytes
scraper scrape html using domxml return rip html data from file or url and display
by editing html t
ags to search for

domxml dom xml content scraper
dom-xml-scraper date added Jan 2013

<?php

$html
=
 
file_get_contents($html);

// check if DomXML is ava
ilable:
if (!
function_exists('DomDocument')){

    die(
'DomXML extens
ion is not available :-('
);
}
 
print 
'<pre>';
 
// create new DO
M object:
$
dom = new DomDocument();
 
// load HTML code:
$dom->loa
dHtml
($html);
 
// get tags by tagname (all 
<atags links):
$tag
$dom->getElementsByTagName('a');
 
// loop trough all links:
fo
reach 
($
tags as $a){
 
    print 
'<b>' $a->nodeValue '</b><br/>'
;
 
    
// does this tag have attribute
s:
    if (
$a->hasAttributes
()){    
 
        
// loop trough all attributes:
        
foreach (
$a-
>
attributes as $attribute){      
            print 
'- ' $attrib
ute
->name ': ' $attribute->va
lue
;
            print 
"<br/>";     
           
        }
    }
 
    print 
"<hr/>";
}
 
print 
'</p

re>'
;

?>


Post a comment

No comments yet

Search ScriptsnTips


Php JavaScripts CGI/Perl