I need to scrap the following elements inside each one of these div’s class=”product-grid-item” (page contains several of them), but in fact I have no clue how to do it… so, I need help not to pull my hair out. 1 – The link and image inside the div: class=”product-element-top2; <a href=”https://…this_link” class=”product-image-link”> (just need the link) <img width=”300″ height=”300″
Tag: dom
php DOMDocument removeChild throws exception of not found
remove is failing with not found exception. Answer You could remove it from the parentNode from $a
How to successfully modify in PHP the DOM of the Document of a CSS class in my case?
I am trying to modify (replace) with DomDocument the attribute of the new CSS class of the a tag (framed on the following screenshot in green) which I have checked well with the function stripos and try to replace its href attribute (i.e. replace the href attribute of the a tag with new CSS class) with str_ireplace: My following PHP
Add domain to src attribute value if a relative path
I have a text variable which contains multiple images with a relative or absolute path. I need to check if the src attribute starts with http or https then ignore it, but in case it starts with / or something like abc/ then prepend a base url. I tried like below: My output is: Issue here: I got 99% result
How to edit large XML files in PHP based on a record in the XML Node
I’m trying to modify a 130mb+ XML file via PHP so it only shows the results where a child node is a specific value. I’m trying to filter this because of limitations via the software we’re using to import the XML into our website. Example: (mockup data) Desired result: I want to create a new XML file with only the
Remove Child does not contain attribute value
I am practicing with XML DOM PHP parsing. I have such XML file (shorter version): I created attribute with name “id” and value “2” for two Tag elements. Now I would like to: Get only Tag elements which did not contain attribute ‘id=”2″‘; Get only Tag elements which contain only ‘id=”2″‘. For first case I created such code. Don’t know
Using AJAX to GET a PHP file in my HTML document, but the scripts inside it aren’t working
I am calling a php file, into my HTML document using AJAX, and it is working too. The problem is that, there are few script tags in that PHP files, which works just fine if the PHP files is viewed individually. But when I call it using AJAX, those scripts are not functioning. I am attaching my PHP code, and
replace li tag with different tag according to the bullet level
need to replace the li tags with different customized tag according to the bullet level, For the li level1 keep it as is, for level2 change li to lii, for level3 change li to liii For example for the input below (I have only 2 bullet levels in the below code just as example) desired output as you can see
Why using DOMDocument makes site load slower?
I’m using DOMDocument with xpath to load some data to my site from external (fast) website. Right now I use 4 urls (please see below). I need to increase to 8 urls. What I have noticed, that the more of those you add, the more slower the site loads. Is there any way to use xpath for more faster load?
Replace ALT attribute with image caption + ACF relationship URL if it exists
I have this WordPress function working, but it has 1 obvious issue in testing and I’m sure many other formatting issues. I’ve pulled this function together from various pieces but would greatly appreciate feedback on cleaning it up. Purpose of the function Modify ALT attribute of any image in a WordPress gallery Get image caption field and add to ALT