fork download
  1. <?php
  2.  
  3. $xml = "<root><entry><link rel='edit' type='application/atom+xml' href='http://w...content-available-to-author-only...r.com/feeds/2202110476673931679/6339893542751280730/comments/default/1280042367141045524'/>
  4.  
  5. <link rel='self' type='application/atom+xml' href='http://w...content-available-to-author-only...r.com/feeds/2202110476673931679/6339893542751280730/comments/default/1280042367141045524'/>
  6.  
  7. <link rel='alternate' type='text/html' href='http://m...content-available-to-author-only...t.com/2016/04/blog-post_11.html?showComment=1460801110852#c1280042367141045524' title=''/></entry>
  8.  
  9. <entry><link rel='edit' type='application/atom+xml' href='http://google.com/'/>
  10.  
  11. <link rel='self' type='application/atom+xml' href='http://j...content-available-to-author-only...n.in/'/></entry></root>";
  12.  
  13. $node = new DOMDocument;
  14. $node->loadXML($xml);
  15.  
  16. foreach($node->getElementsByTagName("entry") as $entry)
  17. {
  18. $link = $entry->getElementsByTagName("link");
  19.  
  20. echo $node->getElementsByTagName('link')->item(0)->getAttribute('href')."<br/>";
  21. echo $node->getElementsByTagName('link')->item(1)->getAttribute('href')."<br/>";
  22. echo ($link->length > 2)?$node->getElementsByTagName('link')->item(2)->getAttribute('href'):"No alternate link!"."<br/>";
  23. }
  24. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
	http://w...content-available-to-author-only...r.com/feeds/2202110476673931679/6339893542751280730/comments/default/1280042367141045524<br/>http://w...content-available-to-author-only...r.com/feeds/2202110476673931679/6339893542751280730/comments/default/1280042367141045524<br/>http://m...content-available-to-author-only...t.com/2016/04/blog-post_11.html?showComment=1460801110852#c1280042367141045524http://w...content-available-to-author-only...r.com/feeds/2202110476673931679/6339893542751280730/comments/default/1280042367141045524<br/>http://w...content-available-to-author-only...r.com/feeds/2202110476673931679/6339893542751280730/comments/default/1280042367141045524<br/>No alternate link!<br/>