arndale65
asked on
javascript xml parsing
Hi,
I have the following XML....
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>Push Entertainment Playlist</title>
<link>http://www.pushentertainment.com</link>
<item>
<title>Media Item 1</title>
<media:content url="video.flv" type="video/x-flv"/>
<description>Media Item 1 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
<item>
<title>Media Item 2</title>
<media:content url="video.flv" type="video/x-flv" />
<description>Media Item 4 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
<item>
<title>Media Item 3</title>
<media:content url="video.flv" type="video/x-flv" />
<description>Media Item 4 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
<item>
<title>Media Item 4</title>
<media:content url="video.flv" type="video/x-flv" />
<description>Media Item 4 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
</channel>
</rss>
The xml is loaded OK but I'm struggling with the syntax to access the nodes. I want....
title, content url, content type, description & thumbnail url
... for each <item>. What JS do I need?
I have the following XML....
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>Push Entertainment Playlist</title>
<link>http://www.pushentertainment.com</link>
<item>
<title>Media Item 1</title>
<media:content url="video.flv" type="video/x-flv"/>
<description>Media Item 1 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
<item>
<title>Media Item 2</title>
<media:content url="video.flv" type="video/x-flv" />
<description>Media Item 4 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
<item>
<title>Media Item 3</title>
<media:content url="video.flv" type="video/x-flv" />
<description>Media Item 4 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
<item>
<title>Media Item 4</title>
<media:content url="video.flv" type="video/x-flv" />
<description>Media Item 4 Description</description>
<media:thumbnail url="preview.jpg" />
</item>
</channel>
</rss>
The xml is loaded OK but I'm struggling with the syntax to access the nodes. I want....
title, content url, content type, description & thumbnail url
... for each <item>. What JS do I need?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The basic code is from w3schools http://www.w3schools.com/XML/tryit.asp?filename=tryxml_httprequest_js4 but I edited the onResponse function so it reads from your XML file's structure instead!
ASKER
Perfect, thankyou.
http://think2loud.com/reading-xml-with-jquery/