Pastoid

SimpleXML Parsing

The page you are looking at now is at this URL: http://pastoid.com/asp

This paste was last updated on March 13, 2009 at 12:07 pm.

sxml.phpraw

<?php
 
$xml = <<< END_XML
<rsp stat="ok">
<comments photo_id="3279857477">
<comment id="155060-3279857477-72157613848274547" author="49186882@N00" authorname="Dr. ZAx" datecreate="1234752408" permalink="http://www.flickr.com/photos/sillyness/3279857477/#comment72157613848274547">
Without a little bit more context, these are very difficult to care that much about. Having said that, I'd choose this one. Feels like there's something I'm missing, just over the horizon.
</comment>
<comment id="155060-3279857477-72157613848274548" author="49186883@N00" authorname="Dr. ZAx" datecreate="1234752408" permalink="http://www.flickr.com/photos/sillyness/3279857477/#comment72157613848274547">
Without a little bit more context, these are very difficult to care that much about. Having said that, I'd choose this one. Feels like there's something I'm missing, just over the horizon.
</comment>
</comments>
</rsp>
END_XML;
 
$x = new SimpleXMLElement($xml);
 
echo (string)$x->comments->comment[0]['author']; // Outputs '49186882@N00'
echo (string)$x->comments->comment[1]['author']; // Outputs '49186883@N00'
 
?>

Toggle wordwrap

Referring DomainHits
Unknown Referer 127
pastoid.com 9
search.live.com 1
Is this paste spam?
<Hide