Hi

Why can't I parse xml with that code?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Data;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Linq;
using System.Diagnostics;

namespace TelSearchModule
{
    public partial class _Default : System.Web.UI.Page
    {




        protected void Page_Load(object sender, EventArgs e)
        {
            ///Start Test
            ///

            string xml;
            using (var web = new WebClient())
                xml = web.DownloadString("http://tel.search.ch/
examples/api-response.xml");

            XNamespace ns = "http://www.w3.org/2005/Atom";;
            XNamespace ns2 = "http://a9.com/-/spec/opensearchrss/
1.0/";
            XNamespace ns3 = "http://tel.search.ch/api/spec/result/
1.0/";


            var descendants = from i in
XDocument.Parse(xml).Descendants(ns + "entry")
                              select new
                              {
                                  totalResults =
i.Element(ns2+"totalResults").Value,
                                  //title = i.Element(ns +
"title").Value,
                                  firstName = i.Element(ns3 +
"firstname").Value
                              };
}}}

Reply via email to