コード例 #1
0
ファイル: Sajtkarta.cs プロジェクト: Edminsson/Charlatan
        public static Sajtkarta GetSajtkarta()
        {
            Sajtkarta sajtkarta = new Sajtkarta
            {
                Urler = new List<Sajtrad>
                {
                    new Sajtrad { Location = "http://charlataner.azurewebsites.net/"},
                    new Sajtrad { Location = "http://charlataner.azurewebsites.net/Details/dmnglr"},
                    new Sajtrad { Location = "http://charlataner.azurewebsites.net/Details/sblcvd"}
                }
            };

            return sajtkarta;
        }
コード例 #2
0
        private string SerialiseraSajtkarta(Sajtkarta sajtkarta)
        {
            XmlSerializer srlr = new XmlSerializer(sajtkarta.GetType());
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add(string.Empty, "http://www.sitemaps.org/schemas/sitemap/0.9");

            //MemoryStream ms = new MemoryStream();
            //srlr.Serialize(ms, sajtkarta, ns);

            string serialiseradSajtkarta;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream))
                {
                    srlr.Serialize(xmlWriter, sajtkarta, ns);
                }

                serialiseradSajtkarta = Encoding.UTF8.GetString(memoryStream.ToArray());

            }

            return serialiseradSajtkarta;
        }