Skip to content

Instantly share code, notes, and snippets.

@mach3
Created December 13, 2010 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mach3/739067 to your computer and use it in GitHub Desktop.
Save mach3/739067 to your computer and use it in GitHub Desktop.
Get the feed informations using xpath.
<?php
$dom = @DOMDocument::loadHTMLFile( $url );
$xpath = new DOMXpath( $dom );
$query = "//link[ @rel='alternate' and ( @type='application/x.atom+xml' or "
. "@type='application/atom+xml' or @type='application/xml' or @type='text/xml' or "
. "@type='application/rss+xml' or @type='application/rdf+xml' ) ]";
$elements = $xpath->query( $query );
foreach( $elements as $element ){
echo "{$element->getAttribute('href')} ({$element->getAttribute('type')})";
echo "<br />";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment