Untitled
unknown
plain_text
3 years ago
2.6 kB
11
Indexable
using System.Xml.Serialization;
namespace WinFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[Serializable()]
public class url
{
[System.Xml.Serialization.XmlElement("loc")]
public string loc { get; set; }
[System.Xml.Serialization.XmlElement("lastmod")]
public string lastmod { get; set; }
[System.Xml.Serialization.XmlElement("changefreq")]
public string changefreq { get; set; }
}
[Serializable()]
[XmlRoot("urlset", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public class CarCollection
{
[XmlArray("urlset")]
[XmlArrayItem("url", typeof(url))]
public url[] url { get; set; }
}
[XmlRoot(ElementName = "url", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public class Url
{
[XmlElement(ElementName = "loc", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public string Loc { get; set; }
[XmlElement(ElementName = "lastmod", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public string Lastmod { get; set; }
[XmlElement(ElementName = "changefreq", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public string Changefreq { get; set; }
[XmlElement(ElementName = "priority", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public string Priority { get; set; }
}
[XmlRoot(ElementName = "urlset", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public class Urlset
{
[XmlElement(ElementName = "url", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public List<Url> Url { get; set; }
[XmlAttribute(AttributeName = "xmlns")]
public string Xmlns { get; set; }
}
private void Form1_Load(object sender, EventArgs e)
{
var xml = File.ReadAllText("saglik-rehberi.xml");
Urlset cars = null;
string path = "saglik-rehberi.xml";
XmlSerializer serializer = new XmlSerializer(typeof(Urlset));
StreamReader reader = new StreamReader(path);
cars = (Urlset)serializer.Deserialize(reader);
reader.Close();
string sdfd = "";
}
}
}Editor is loading...