Advertisement

07.23.2008 at 01:00PM PDT, ID: 23589952
[x]
Attachment Details

Using XPathNavigator to read Atom XML with ASP.Net

Asked by Epiktet in Extensible Markup Language (XML), Programming for ASP.NET, RSS

Tags: , , ,

I have a XML feed from Youtube that uses the Atom standard, but ASP.Net 2.0 doesn't seem to be able to handle this standard?

The XML feed start as follows:
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'  [...]

I'm using the code posted below, and this works fine as long as I remove the xmlns attribute (xmlns='http://www.w3.org/2005/Atom') in the XML feed, but as I'm getting the feed directly from Youtube I'm not able to edit it myself and need to find a way that ASP.Net 2.0 can read the code "as is".Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
XPathDocument document = new XPathDocument("http://www.epiktet.no/feeds/youtubefeed.xml");
XPathNavigator navigator = document.CreateNavigator();
XPathNodeIterator nodes = navigator.Select("/feed/entry/id");
 
nodes.MoveNext();
XPathNavigator nodesNavigator = nodes.Current;
       
XPathNodeIterator nodesText = nodesNavigator.SelectDescendants(XPathNodeType.Text, false);
 
string youtubeVideoID = nodesText.Current.Value.ToString();
[+][-]07.24.2008 at 06:18AM PDT, ID: 22078753

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 06:24AM PDT, ID: 22078805

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible Markup Language (XML), Programming for ASP.NET, RSS
Tags: Microsoft, ASP.net, 2.0, C#
Sign Up Now!
Solution Provided By: abel
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.24.2008 at 01:07PM PDT, ID: 22083010

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 01:27PM PDT, ID: 22083217

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628