tass2001 Posted December 7, 2007 Share Posted December 7, 2007 Hey im using the following code to snip out info from a myspace profile <?php $dom = new domdocument; $url = 'http://www.myspace.com/yourprofile'; @$dom->loadHTMLFile($url); $xpath = new domxpath($dom); $xNodes = $xpath->query('//td'); echo '<ul>'; foreach ($xNodes as $xNode) { $content = @$xNode->firstChild->data; $contentId = $xNode->getAttribute('id'); if ($content != '' && $contentId != '') { echo $contentId; echo " - "; echo $content; echo '<br>'; } } ?> But I would also like it to preform the following function echo '<span style="font-size: 12px; font-family: Verdana">'; $pieces = explode("About me:(/span><br/>", $result); $aboutme = $pieces[1]; $pieces = explode("<span class=\"text\"><div style=\"display:none;\">", $aboutme); $aboutme = $pieces[1]; $pieces = explode("</div>", $aboutme); $aboutme = $pieces[0]; $aboutme = str_replace("\r\n", "<br>", $aboutme); echo "<b><u>About me</u></b>".$aboutme."<br>" ; # <-- missing how would I do that? Link to comment https://forums.phpfreaks.com/topic/80679-xpath-code-snippets/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.