I need help some help printing out some xml. Here is my code (which isnt working its not even formatting the full url right, it doesnt understand "//" in the url string) It also doesnt understand "<". There must be a better way to do this??
foreach (string url in theUrls)
{
fullurl=@"http://www.cambit.com/restaurants" +url;
xml = xml + @"<url>" + Environment.NewLine +
@"<loc>" + fullurl + @"</loc>" + Environment.NewLine +
@"<changefreq>weekly</changefreq>" + Environment.NewLine +
@"<priority>0.80</priority>" + Environment.NewLine +
@"</url>" + Environment.NewLine;
}
It returns 400 of these appended right next to each other. Environment.NewLine isn't working either....
http://www.cambit.com/restaurantsBerwyn weekly 0.80
I tried this and it says the loc object is not set to an instance of an object
XmlDocument aNewNode = new XmlDocument();
XmlElement urlRoot = aNewNode.CreateElement("url");
//aNewNode.DocumentElement.AppendChild(urlRoot);
XmlElement loc = aNewNode.CreateElement("loc");
XmlText locText = aNewNode.CreateTextNode(fullurl);
aNewNode.DocumentElement.AppendChild(loc);
aNewNode.DocumentElement.LastChild.AppendChild(locText);
XmlElement chgFreq = aNewNode.CreateElement("changefreq");
XmlText chgFreqText = aNewNode.CreateTextNode("weekly");
aNewNode.DocumentElement.AppendChild(chgFreq);
aNewNode.DocumentElement.LastChild.AppendChild(chgFreqText);
XmlElement priority = aNewNode.CreateElement("priority");
XmlText priorityText = aNewNode.CreateTextNode("0.80");
aNewNode.DocumentElement.AppendChild(priority);
aNewNode.DocumentElement.LastChild.AppendChild(priorityText);
What am doing wrong??