0

I'm using simplexml() function to parse through RSS feed, while i can access $var->title to <title> how do I access <dcterms:issued>?

Feed excerpt (http://pastebin.com/nN8G78AH):

<item rdf:about="http://newyork.craigslist.org/brk/mcy/1779690213.html">
  <title><![CDATA[Kawasaki ZX-10R Rims For Sale (Nassau Motorsports)]]></title>
  <link>http://newyork.craigslist.org/brk/mcy/1779690213.html</link>
  <description><![CDATA[
<br>

<br>
2000 KAWASAKI ZX-12R
<br>

<br>
FRONT & REAR RIMS W/FRONT & REAR ROTORS
<br>

<br>
RIMS ARE IN BOLT ON CONDITION .. RIM ARE CHARCOAL BLACK .. ASKING 400.00 OBO
<br>

<br>
CALL 516-216-5768 FOR MORE INFO]]></description>
  <dc:date>2010-06-07T13:04:07-04:00</dc:date>
  <dc:language>en-us</dc:language>
  <dc:rights>Copyright &#x26;copy; 2010 craigslist, inc.</dc:rights>
  <dc:source>http://newyork.craigslist.org/brk/mcy/1779690213.html</dc:source>
  <dc:title><![CDATA[Kawasaki ZX-10R Rims For Sale (Nassau Motorsports)]]></dc:title>
  <dc:type>text</dc:type>
  <dcterms:issued>2010-06-07T13:04:07-04:00</dcterms:issued>
</item>
hakre
  • 193,403
  • 52
  • 435
  • 836
alexus
  • 7,256
  • 12
  • 44
  • 66

1 Answers1

2

Are you using SimpleXML?

A solution for you seems to exist right here.

EDIT

Answer copied here for posterity's sake

Access the children by their XML namespace.

$dcChildren = $node->children( 'http://purl.org/dc/elements/1.1/' );

$title = $dcChildren->title;
Peter Bailey
  • 105,256
  • 31
  • 182
  • 206
  • 1
    `$node->children('dc',true);` would be somewhat more readable for those who don't know the standard dc: namespace. – Wrikken Jun 07 '10 at 19:55
  • 1
    @Wrikken It's important to know the disadvantage of using the alias/prefix, namely that the XML generator is free to change it without changing the meaning, since the URI is the actual identifier. For readability, a constant like `define('XMLNS_DUBLIN_CORE', 'http://purl.org/dc/elements/1.1/');` would be both readable and future-proof. – IMSoP May 19 '13 at 15:23