simple-html-dom

How Can I extract the image path from <ri:attachment ri:filename=“stories-img-05.png” />

落爺英雄遲暮 提交于 2021-02-20 04:14:07
问题 Here is the original code where I am extracted the data using Simple HTML Dom: <div class="content-wrapper"><p><ac:image ac:height="250"><ri:attachment ri:filename="stories-img-05.png" /></ac:image></p></div> Here is the code which i am using : $html->find('div[class=content-wrapper] p ac:image ', 0)->innertext; How can I get Image Path? 回答1: For multiple use this code: $img=array(); foreach($html->find('div.content-wrapper ri:attachment[ri:filename]') as $article) { array_push($img, $article

Exclude non wanted html from Simple Html Dom - PHP

笑着哭i 提交于 2021-01-29 13:25:26
问题 I am using HTML Simple Dom Parser with PHP to get title, description and images from a website. The issue I am facing is I am getting the html which I dont want and how to exclude those html tags. Below is the explanation. Here is a sample html structure which is being parsed. <div id="product_description"> <p> Some text</p> <ul> <li>value 1</li> <li>value 2</li> <li>value 3</li> </ul> // the div I dont want <div id="comments"> <h1> Some Text </h1> </div> </div> I am using below php script to

Get text value with PHP simple HTML DOM parser

◇◆丶佛笑我妖孽 提交于 2021-01-28 14:19:16
问题 How can I get the text value where <span>Your name:<span> with the PHP simple HTML DOM parser without children command? <div class="adds-info"> <span>price:<span>1000000000 </span></span> <span>txt1</span> <span>Your name:<span>aaa</span></span> <span>Phone:<span>02632402210</span></span> </div> PHP simple HTML DOM parser api 回答1: Assuming the HTML in your post is in a variable $str , this is fairly straightforward: // Parse the HTML string into a DOM object $html = str_get_html($str); //

PHP: Simple HTML DOM Parser - how to get the element which has certain content?

早过忘川 提交于 2021-01-05 06:49:54
问题 In PHP I'm using the Simple HTML DOM Parser class. I have a HTML file which has multiple A-tags. Now I need to find the tag that has a certain text inside. for example : $html = "<a id='tag1'>A</a> <a id='tag2'>B</a> <a id='tag3'>C</a> "; $dom = str_get_html($html); $tag = $dom->find("a[plaintext=B]"); The above example doesn't work, since plaintext can only be used as an attribute. Any idea's? 回答1: <?php include("simple_html_dom.php"); $html = "<a id='tag1'>A</a> <a id='tag2'>B</a> <a id=

PHP: Simple HTML DOM Parser - how to get the element which has certain content?

若如初见. 提交于 2021-01-05 06:47:53
问题 In PHP I'm using the Simple HTML DOM Parser class. I have a HTML file which has multiple A-tags. Now I need to find the tag that has a certain text inside. for example : $html = "<a id='tag1'>A</a> <a id='tag2'>B</a> <a id='tag3'>C</a> "; $dom = str_get_html($html); $tag = $dom->find("a[plaintext=B]"); The above example doesn't work, since plaintext can only be used as an attribute. Any idea's? 回答1: <?php include("simple_html_dom.php"); $html = "<a id='tag1'>A</a> <a id='tag2'>B</a> <a id=

Finding part with simple html dom parser by two or more attributes per one element

一曲冷凌霜 提交于 2020-06-25 04:55:08
问题 I would like to say, that I know, that many think, that Simple HTML DOM parser is a really bad choice for HTML parser. Still I need to use it at the moment. I read some articles where it was described how to search by two or more attributes per one element. They proposed something like that and one possibility with array filtering foreach ( tag[attr1=value] as tag1 ) { foreach ( tag[attr2=value] as tag2 ) { // print tag2[attr1=value,attr2=value] } } My question is about native posibility for

Finding part with simple html dom parser by two or more attributes per one element

孤街醉人 提交于 2020-06-25 04:55:08
问题 I would like to say, that I know, that many think, that Simple HTML DOM parser is a really bad choice for HTML parser. Still I need to use it at the moment. I read some articles where it was described how to search by two or more attributes per one element. They proposed something like that and one possibility with array filtering foreach ( tag[attr1=value] as tag1 ) { foreach ( tag[attr2=value] as tag2 ) { // print tag2[attr1=value,attr2=value] } } My question is about native posibility for