domparser

Dom parser in android 4.0 API

天大地大妈咪最大 提交于 2019-12-31 04:22:08
问题 My Problem is Dom Parser is not working in Android 4.0 but it's working on 2.2, if i run the project in my 4.0 emulator than below line not execute and this is not give any error. Document doc = db.parse(inStream); Following is my Java Code:- public class TestParsingActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); StringBuffer sb = new

PHP Simple HTML Dom Parser Memory Leak / Usage

五迷三道 提交于 2019-12-30 03:43:06
问题 I'm trying to use PHP Simple HTML Dom Parser to parse some information from some sites. Does not matter what and where. But it seems, that there is some HUGE memory problem with it. I managed to cut the html code to only 6kB, but script that finds some elements and saves them to database takes even 700MB of ram and over 1GB of virtual memory! I read somewhere that I should use ->clear() to free up some memory, but seems that this is not the case. I use str_get_html() once and 5 times using -

How to web-scrape DL's DT and DD which is under a div with DOMparser/Xpath

我怕爱的太早我们不能终老 提交于 2019-12-25 04:14:10
问题 I am trying to get DL's DT and DD which is under a class and trying to put those in a foreach. But facing some troubles, <dl class="c-explain2"> <dt>所在地</dt> <dd> 大阪府大阪市 北区天満1丁目25番1(地番) <br> Here is my codes; $DOMParser = new \DOMDocument(); $DOMParser->loadHTML($html); $xpath = new \DOMXPath($DOMParser); $classname="c-explain2"; $getAllTable = $xpath->query("//dl[contains(@class, '$classname')]//"); foreach($getAllTable as $table){ $allProperties = []; $table->getElementsByTagName('dt')[0]-

I can't grab specific URL in search page

北城余情 提交于 2019-12-25 00:23:33
问题 I enter the estate website and searched by name of the city. After that I want to grab Osaka City building URL. In here http://brillia.com/search/?area=27999   There are four of those.   And I m using that link to grab URL. $allDivs = $parser->getElementsByTagName('div'); foreach ($allDivs as $div) { if ($div->getAttribute('class') == 'boxInfomation') { $allLinks = $div->getElementsByTagName('a'); foreach ($allLinks as $a) { $linkler[] = $a->getAttribute('href'); } } } But I cant grab those.

Fetching all images src from specific div

故事扮演 提交于 2019-12-24 16:56:02
问题 Suppose, I have HTML structure like: <div> <div class="content"> <p>This is dummy text</p> <p><img src="a.jpg"></p> <p>This is dummy text</p> <p><img src="b.jpg"></p> </div> </div> I want to fetch all image src from .content div. I tried : <?php // a new dom object $dom = new domDocument; // load the html into the object $dom->loadHTML("example.com/article/2345"); // discard white space $dom->preserveWhiteSpace = false; //get element by class $finder = new DomXPath($dom); $classname =

DOMParser().parseFromString() not giving response with Firefox

隐身守侯 提交于 2019-12-24 16:37:24
问题 I built a chrome extension and everything worked well. Now i need to put it on firefox, and it's a f*** mess. The problem is with dom parsing. Her's the code that doesn't work on FF : var parser = new DOMParser(); SOURCE_DOM = parser.parseFromString(data.url, "text/html"); SOURCE_DOM always return an object empty : Object : {location : null} On chrome there's no problem with that, it gives me the document object and i can properly work with it. But Firefox is a pain in the ass compared to

Find stacked div class with Simple HTML DOM Parser

為{幸葍}努か 提交于 2019-12-24 02:16:43
问题 I am using PHP Simple HTML DOM Parser and there is a section in the html page with the following source: <div class="box-content padding-top-1 padding-bottom-1 font-size-3"> <ul> <li> <a href="link1">linkdescription 1</a> </li> <li> <a href="link2">linkdescription 2</a> </li> </ul> </div> How can I now get the list of links with using the stacked class identifier? Here's what I've currently tried: List item $html->find('.box-content padding-top-1 padding-bottom-1 font-size-3')); returns empty

javascript, how to remove the <html><head><body> elements when using DOMparser with text/html

倖福魔咒の 提交于 2019-12-23 12:34:30
问题 The code var txt = '<div id="hi">fe</div><div id="h2">fe</div><div id="hj">fe</div>' var parser = new DOMParser(); var temp_node = parser.parseFromString(txt, "text/html").documentElement; console.log(temp_node) This code results in the full html document, this is including <html><head></head><body> <div id="hi">fe</div> <div id="h2">fe</div> <div id="hj">fe</div> </body></html> What if I want only the <div id="hi">fe</div><div id="h2">fe</div><div id="hj">fe</div> part? How can I do it? And,

Parsing XMLHttpRequest() result (using XPath)

坚强是说给别人听的谎言 提交于 2019-12-21 22:45:06
问题 I need in JavaScript to load in variable contents of another page from the same site and then get data from that contents (parse XML). I have gotten in text string variable the page's HTML using XMLHttpRequest() and responseText property. After that I converted text string into xml object (DOMParser) and tried to use XPath. In FireFox's console I saw error: Node cannot be used in a document other than the one in which it was created How can I convert XMLHttpRequest() result into document

troubles trying to parse an html string with DOMParser

白昼怎懂夜的黑 提交于 2019-12-21 20:05:21
问题 here's come the snippet : html = "<!doctype html>"; html += "<html>"; html += "<head><title>test</title></head>"; html += "<body><p>test</p></body>"; html += "</html>"; parser = new DOMParser(); dom = parser.parseFromString (html, "text/html"); here's come the error when trying to execute these lines : Error: Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOMParser.parseFromString] I try to figure out what's going on but the code seems to be right and I searched on