0

I was wondering if I would be able to extract the text of the any HTML Element using PHP.

For eg. <a> Hello World </a> Then Extract Hello World from it or able to manipulate it.

I tried using DOM to access certain attribute Like

$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTMLFile("C:\\Users\\Ahmar Zafar\\Desktop\\SentimentAnalysis-master\\Website\\index.html")
$plink = $doc->getElementById("first");
$plink->setAttribute("src", "http://www.google.com");
$doc->saveHTMLFile("C:\\Users\\Ahmar Zafar\\Desktop\\SentimentAnalysis-master\\Website\\index.html");

This seemed to work for the attributes but when I need a solution for InnerHTML. I want to change the inner html dynamically. Please Help me Rectify this problem or suggest some solution.

0 Answers0