TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sourabh choubey
NA
174
46k
dont use foreach loop to write xml in controller in mvc..
Jul 26 2016 3:43 AM
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();
Reply
Answers (
2
)
Send email using my own domain hosting server
Query builder for different data source