php - unable to parse xml file attributes -


i have following xml file facing problem in parsing attributes of staff list.how staff:name , 'staff:image`.

<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/atom" xmlns:course="https://www.edx.org/api/course/elements/1.0/" xmlns:staff="https://www.edx.org/api/staff/elements/1.0/" version="2.0"> <channel>  <title>edx.org course feed</title>  <link>https://www.edx.org/api/v2/report/course-feed/rss</link>  <atom:link rel="first" href="https://www.edx.org/api/v2/report/course-feed/rss"/>  <atom:link rel="last" href="https://www.edx.org/api/v2/report/course-feed/rss?page=12"/>  <atom:link rel="previous" href="https://www.edx.org/api/v2/report/course-feed/rss?page=11"/>  <atom:link href="https://www.edx.org/api/v2/report/course-feed/rss" rel="self" type="application/rss+xml"/>  <description>edx.org - course catalog feed</description>  <language>en</language>  <item>  <title>quantum mechanics of molecular structures</title>  <course:instructors>   <course:staff>    <staff:name>kaoru yamanouchi</staff:name>    <staff:title/>    <staff:bio>      professor kaoru yamanouchi has been professor of chemistry @ university of tokyo since april 1997. research fields in physical chemistry; especially, gas phase laser spectroscopy, chemical reaction dynamics, , intense laser science. 1 of world-leading scientists in new interdisciplinary research field called ultrafast intense laser science. has been recipient of morino fellowship endowed morino foundation (1987), spectroscopical society of japan award high-quality papers (1989), chemical society of japan award young scientists (1991), japan ibm prize (2000), best paper award of laser society of japan (2008), , chemical society of japan award (2015).    </staff:bio>    <staff:image>     https://www.edx.org/sites/default/files/person/image/photoyamanouchi110x110.jpg    </staff:image>    </course:staff>  <course:staff> </course:instructors> </item> </channel> </rss> 

how can parse course:instructors list.
far code is:

 $rss = simplexml_load_file('https://www.edx.org/api/v2/report/course-feed/rss?page=12');  $namespaces = $rss->getnamespaces(true);//add line  echo '<h1>'. $rss->channel->title . '</h1>';  foreach ($rss->channel->item $item) {    $title = $item->title ;    echo '<h2><a href="'. $item->link .'">' . $title . "</a></h2>";    $course = $item->children($namespaces['course']);  } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -