SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    West Lafayette, IN
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Extracting URL from malformed anchor tag

    I am trying to create an RSS feed for my school's newspaper via the PHP5 DOM support. I main page from their website around 1am via curl and then run HTML tidy on it to clean it up.

    Once clean, I use PHP to extract the href attribute as the <link> tag for the RSS feed. The problem I am having is setting a title. Unfortunately, no one on my school's paper knows what a "title" attribute is, so I can't use the same method I used for getting the URL.

    how can i go about getting the value between the <a></a> tags? here is the relevant code I have so far.

    Code:
    <?php
    	foreach ($params as $param) {	
    		if (!substr_compare($param -> getAttribute('href'), $strValue, 0, $strLength, true)) {
    			echo "<item>\n";
    			echo "\t\t\t<title>" . "nothing here yet" . "</title>\n";
    			echo "\t\t\t<link><![CDATA[http://www.purdueexponent.com" . trim($param -> getAttribute('href')) . "]]></link>\n";
    			echo "</item>\n";			
    		}
    	}
    ?>

  2. #2
    SitePoint Member
    Join Date
    Sep 2004
    Location
    West Lafayette, IN
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just an update, i tried to use preg_match, but then realized it wanted a string and DOM is spitting objects at me. So much for that idea.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •