xtw.Formatting = Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteStartElement("rss");
xtw.WriteAttributeString("version", "2.0");
xtw.WriteAttributeString("xmlns:g", "http://base.google.com/ns/1.0");
xtw.WriteStartElement("channel");
xtw.WriteElementString("title", "Globy");
xtw.WriteElementString("link", "http://www.globy.com.tr");
xtw.WriteElementString("description", açiklama);
foreach (Urun urunum in urunler)
{
xtw.WriteStartElement("item");
xtw.WriteElementString("title", urunum.Adi);
xtw.WriteElementString("link", Partial.urunLink(urunum.ID));
xtw.WriteElementString("description", urunum.DetayAciklamasi);
xtw.WriteElementString("g:id", urunum.Kodu);
xtw.WriteElementString("g:condition", "new");
xtw.WriteElementString("g:price", urunum.SatisFiyati1.ToString());
xtw.WriteElementString("g:availability", "in stok");
xtw.WriteElementString("g:image_link",">http://www.globy.com.tr/Resim/Urun/Buyuk/"+ Partial.urunResim(urunum.ID));
xtw.WriteStartElement("g:shipping");
xtw.WriteElementString("g:country", "TR");
xtw.WriteElementString("g:service", "Standart");
xtw.WriteElementString("g:price", urunum.SatisFiyati1.ToString());
xtw.WriteEndElement();
xtw.WriteElementString("g:gtin",urunum.ID.ToString());
xtw.WriteElementString("g:brand", urunum.Kategori.Adi);
xtw.WriteElementString("g:mpn", urunum.Kodu);
xtw.WriteElementString("g:product_type", urunum.KisaAciklamasi);
xtw.WriteEndElement();
}
xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.WriteEndDocument();
xtw.Flush();
xtw.Close();
return Content(writer.ToString(), "text/xml", Encoding.UTF8);
////////////////////////////// ayri bir classda
public class StringWriterWithEncoding : StringWriter
{
private Encoding _enc;
public StringWriterWithEncoding(Encoding NewEncoding)
: base()
{
_enc = NewEncoding;
}
public override System.Text.Encoding Encoding
{
get
{
return _enc;
}
}
}
Yazar: Ali Karayel
Makale Tarihi: 07.11.2017 Gücellenme Tarihi: 07.11.2017

Yorum Yaz

Yorumlarınız denetimden geçtikten sonra yayınlanmaktadır...

Makale Etiketleri