php - How can i get text from Tags? -


i have question.how can text between tags in html??

<reviewsclientmodel xmlns:i="http://www.w3.org/2001/xmlschema-instance" xmlns="http://schemas.datacontract.org/2004/07/microsoft.onestore.site.models"> <items> <reviewsclientmodel.reviewclientmodel> <helpfulnegative>0</helpfulnegative> <helpfulpositive>2</helpfulpositive> <ispublished>true</ispublished> <istakendown>false</istakendown> <rating xmlns:d4p1="http://schemas.datacontract.org/2004/07/microsoft.onestore.site.models.viewmodels"> <reviewid>5ce5dc85-466d-a1cc-efe7-70bdd5183dfb</reviewid> <reviewtext>i downloaded app had in eyes kinda black don't know is.my cousin thinks not scary creeped out wen saw him myself. whoevers not scared wow wow. safety dont download</reviewtext> <submitteddatetime>2015-06-25t20:13:05.633</submitteddatetime> <title>for safety don"t play</title> <userid>985157380267961</userid> <username>natalie</username> <violationsfound>false</violationsfound> </reviewsclientmodel.reviewclientmodel> 

for example "5ce5dc85-466d-a1cc-efe7-70bdd5183dfb". tried :

public function getxpath($str)     {         \db::connection('mongodb')->disablequerylog();         libxml_use_internal_errors(true);         $str = str_replace("\0", '', $str);         $dom = new \domdocument();         $dom->loadhtml('<?xml encoding="utf-8">' . $str);         return new \domxpath($dom);     } $xpath = $this->getxpath($str); $tmpcommid = $xpath->query("//reviewid");              $comm_id = trim($tmpcommid->item($j)->nodevalue); 

i used curl download web site,and saved in $str.

this answer assuming want use javascript.

you can parse html using pure javascript html parser.

check blog documentation on library. might little outdated.

edit:

larsh informed me wanted xml scraper in php. although should have checked sample code check was, remind people want in.

as answer, whicle i'm not familiar php, dom should able handle pretty well.

in addition, here answer past pretty example of using dom parse html. should easy enough use xml instead. hope helps.


Comments