Jump to content

Xpath Code Snippets


tass2001

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.