Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
dont use foreach loop to write xml in controller in mvc..
sourabh choubey
Jul 26 2016 3:43 AM
188
Reply
I don't want to use foreach loop to write the contents in xml.is there any other way so that we
can not use foreach loop inside the controller to write xml content..
Here is my code..
var blog = _api.GetAllBlogCategory().ToList();
StreamWriter writer = new StreamWriter(Server.MapPath("~/XmlFiles/BlogCategory.xml"));
writer.WriteLine(@"<?xml version=""1.0"" encoding=""utf-8""?>");
writer.WriteLine("<CategoriesBlog>");
foreach(var blogitems in blog)
{
writer.WriteLine("<CategoryBlog ID='" + blogitems.ID + "' Name='" + blogitems.Name + "' ParentId='" + blogitems.ParentID + "' Seo_Discription='" + blogitems.seo_keywords + "' Seo_KeyWords='" + blogitems.seo_keywords + "'>");
writer.WriteLine("</CategoryBlog>");
}
writer.WriteLine("</CategoriesBlog>");
writer.Close();
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Send email using my own domain hosting server
at least one checkbox checked inside datalist