Is there something equivalent to the php DOMdocument class for javascript or angularjs?

1

Location: Given the url, I would need all the classes used within the page.

There is a method of class DomDocument that I would need to use ( ->loadHTMLFile($url) ).

Is there anything equivalent to this class for javascript or angularjs ?

  • I needed to load a url and then search the tags (I would just like to get classes)

    $dom = new DOMDocument;
    $dom->loadHTMLFile('https://www.youtube.com/'); // a url vai aqui
    $elements = $doc->getElementsByTagName('input');
    
    foreach($elements as $el){
        //retorna todas as classes referente aos inputs
        echo $el->getAttribute('class')."\n";
    }
    

In javascript you can only search the current page (where the script is inserted), for example:

  • I wanted to make given a url and hence the search for classes

    var $elements = document.getElementsByTagName('input');
    var show = "";
    for(var i = 0; i < $elements.length; i++){
        var tagClass = $elements[i].getAttribute('class');
        if( tagClass !== null){
            show += tagClass ;
        }
    }
    alert(show);
    
asked by anonymous 02.12.2016 / 16:16

0 answers