Answer the question
In order to leave comments, you need to log in
How to save changes to file using DIDOM library?
Greetings!
There was a problem in work with php library DIDOM. I am loading HTML from a local php file like this: I then
search for the selector , which succeeds because I get an array with one object.
Next, I loop through the $elements array and use $item->setValue('Foo'); to change the text in h1. But this value only changes in the object, not in the php file. Please tell me if I understand correctly that this library should make changes to the file or is this method not for this (setValue) ? How then can I change the text that I found using the div > h1 selector and save it in the file in which the search was made?
$document = new Document('page.html', true);
$elements = $document->find("div > h1");
Answer the question
In order to leave comments, you need to log in
Methods like setValue() operate on an object, they don't save the results to a file)
DiDOM is written on top of DOMDocument and the create method returns a DOMDocument instance ( link ). You can use the save method ( documentation ).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question