Raysefo

Raysefo

  • 1.4k
  • 284
  • 149.6k

How to get specific data from XML?

Aug 23 2010 3:53 AM
Hi,

I want to get specific data from an xml source on the web. (http://www.tcmb.gov.tr/kurlar/today.xml) What i would like to get is, exactly USD forexselling and EUR forexselling values then insert into a table in db. I would be glad if anyone can help.

Thanks in advance.

Best Regards.

Here is my code;
Snippet<
static void Main(string[] args)
        {
            XmlTextReader rdr = new XmlTextReader(" http://www.tcmb.gov.tr/kurlar/today.xml");


            while (rdr.Read())
            {
                if (rdr.NodeType.Equals(XmlNodeType.XmlDeclaration))
                {
                    rdr.Skip();
                }
                else
                {
                    switch (rdr.Name)
                    {
                        case "Isim"Console.WriteLine(rdr.Name);

                            Console.WriteLine(rdr.Value);
                            break;
                        case "ForexSelling"Console.WriteLine(rdr.Name);
                            Console.WriteLine(rdr.Value);
                            break;

                        case "Döviz Satis"Console.WriteLine("Döviz Satis");
                            if (rdr.HasAttributes)    // This fails every time
                                Console.WriteLine("Attribute @type: " + rdr.GetAttribute("Type"));
                            break;
                    }
                }
            }
        }


Answers (1)