Solved

Trouble Parsing XML nodes

Posted on 2011-09-20
3
355 Views
Last Modified: 2013-11-18
I have an XML document loaded from an RSS feed and I want to pick the exchange rate value shown in the dc:value node.

The value should simply be displayed in  Label1.text.

I have been able to read all 23 items from the "item" node but can't seem to get the value from the child nodes. Anyone able to see the problem with this code and the fix for it. I attach the xml document as well.

Please help!
man.AddNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                man.AddNamespace("slash", "http://purl.org/rss/1.0/modules/slash/");
                man.AddNamespace("taxo", "http://purl.org/rss/1.0/modules/taxonomy/");
                man.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
                man.AddNamespace("syn", "http://purl.org/rss/1.0/modules/syndication/");
                man.AddNamespace("admin", "http://webns.net/mvcb/");
                man.AddNamespace("feedburner", "http://rssnamespace.org/feedburner/ext/1.0");
                man.AddNamespace("rss", "http://purl.org/rss/1.0/");

                XmlNodeList xnList = responseXML.SelectNodes("rdf:RDF//rss:item", man);

                bool found = false;
                foreach (XmlNode xn in xnList)
                {
                    XmlNode currencyCODE = xn.SelectSingleNode("descendant::dc:baseCurrency", man);
                    found = (currencyCODE != null) ? true : false;
                    if (found)
                    {
                        if (currencyCODE.InnerText == "AUD")
                        {
                            XmlNode currencyVALUE = xn.SelectSingleNode("descendant::dc:value", man);
                            if (currencyVALUE != null)
                                Label1.Text = currencyVALUE.InnerText;
                        }
                        break;
                    }
                }

Open in new window

201109211103-ExchangeRates.xml
0
Comment
Question by:JenebyM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 36571662
you need to add a namespace

xmlns:cb="http://www.cbwiki.net/wiki/index.php/Specification_1.2/"

                man.AddNamespace("cb", "http://www.cbwiki.net/wiki/index.php/Specification_1.2/");

both value and baseCurrency are NOT in dc: but in cb:
0
 

Author Comment

by:JenebyM
ID: 36571913
Perfect:


0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36571916
welcome
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question