Hi,
Below is the XML schema I am trying to conform to:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/</loc>
<lastmod>2005-01-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Below is what I have managed to produce:
<?xml version="1.0" encoding="utf-8"?>
<urlset>
<url>
<loc>http://www.ign.com</loc>
<lastmod>2005-01-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
As you can see there is one main difference, I can't seem to be able to re-create the attribute string of the 'urlset' element.
Below is the code I am using:
// Create the settings object that will define the settings that our writer will use.
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
settings.Indent = true;
settings.OmitXmlDeclaration = false;
// create the XML writer object.
XmlWriter xmlW = XmlWriter.Create("SiteMap.xml", settings);
// write the start header for the XML document.
xmlW.WriteStartDocument();
xmlW.WriteStartElement("urlset");
xmlW.WriteStartElement("url");
xmlW.WriteElementString("loc", "http://www.ign.com");
xmlW.WriteElementString("lastmod", "2005-01-01");
xmlW.WriteElementString("changefreq", "monthly");
xmlW.WriteElementString("priority", "0.8");
xmlW.WriteEndElement();
xmlW.WriteFullEndElement();
// close the writer.
xmlW.Close();
Console.ReadKey();
My code is simple enough and it still doesn't match the sample xml I was given to conform to. Can you guys help make sure that both sets of xml match each other?