Используя приведенный ниже код, вы можете получить уникальный идентификатор устройства устройства Android OS в виде строки.
deviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
Если это всегда в одном месте, вы можете сделать:
$html->find('.article text', 4);
Здесь вам не нужно simple_html_dom
. Это можно сделать с помощью DOMDocument
и DOMXPath
. Оба являются частью ядра PHP.
Пример:
// your sample data
$html = <<<EOF
<div class="article">
<div style="text-align:justify">
<img src="image.jpg" title="image">
<br>
<br>
"Text to grab"
<div>......</div>
<br></br>
................
................
</div>
</div>
EOF;
// create a document from the above snippet
// if you are loading from a remote url use:
// $doc->load($url);
$doc = new DOMDocument();
$doc->loadHTML($html);
// initialize a XPath selector
$selector = new DOMXPath($doc);
// get the text node (also text elements in xml/html are nodes
$query = '//div[@class="article"]/div/br[2]/following-sibling::text()[1]';
$textToGrab = $selector->query($query)->item(0);
// remove newlines on start and end using trim() and output the text
echo trim($textToGrab->nodeValue);
Выход:
"Text to grab"