public HttpResponseMessage Get() { string kategoriIDTasinirDisk = "1000352"; String path = HttpContext.Current.Server.MapPath("~/xmller"); string stok = Path.Combine(path, "despecStok.xml"); string katalog = Path.Combine(path, "despecKatalog.xml"); XDocument xd = XDocument.Load(stok); XDocument xd2 = XDocument.Load(katalog); var stokBilgisi = xd.Descendants("URUN").Select(p => new { kod = p.Attribute("KOD").Value }).ToList(); ArrayList arrayList = new ArrayList(); xd.Descendants("URUN").Select(s => new { skod = s.Attribute("KOD").Value }).ToList().ForEach(s => { xd2.Descendants("KATEGORI").Where(p => p.Attribute("KOD").Value.Equals("DPC13", StringComparison.OrdinalIgnoreCase)).Descendants("GRUP").Where(p => p.Attribute("KOD").Value.Equals("143", StringComparison.OrdinalIgnoreCase)).Descendants("URUN").Where(p => p.Attribute("KOD").Value.Equals(s.skod, StringComparison.OrdinalIgnoreCase)).Select(p => new { xkod = p.Attribute("KOD").Value, xvergi = p.Element("VERGI").Value, xresim = p.Element("RESIM").Value, xmarka = p.Attribute("AD").Value.ToString().Split(' ').First(), xkapasite = p.Attribute("AD").Value.ToString().Replace(" ", "").Substring(0, p.Attribute("AD").Value.ToString().Replace(" ", "").IndexOf("TB")).Last() }).ToList().ForEach(p => { Console.WriteLine("KOD: " + p.xkod + " VERGI: " + p.xvergi + " RESIM: " + p.xresim + " MARKA: " + p.xmarka + " KAPASITE: " + p.xkapasite + " Tb"); arrayList.Add("KOD: " + p.xkod + " VERGI: " + p.xvergi + " RESIM: " + p.xresim + " MARKA: " + p.xmarka + " KAPASITE: " + p.xkapasite + " Tb"); }); }); return Request.CreateResponse(HttpStatusCode.OK, arrayList); }