Skip to content
Advertisement

Tag: dom

Grabbing specific elements inside DIV from external page

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″

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

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

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?

Advertisement