Insert into XML by Date

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using GridView to load and edit an XML file full of news articles. The page has an extra section that allows me to insert an article into XML. I need to be able to insert an article by date. I am restricted to using ASP.NET 2.0 and C#.
<br/>
<br/>
Sample of the XML document and Code for inserting the article:<br/>
Code:
<pre><NewsArticle>
<Article>
<Date>12/31/2012</Date>
<Author>Test Author</Author>
<Source>Test Source</Source>
<Title>Test Title</Title>
<Summary>Test Summary</Summary>
<NewsLink>www.google.com</NewsLink>
</Article>[/code]
<pre>protected void InsertArticle(object sender, EventArgs e)
{

BindData();
DataSet _DataSet = GridView1.DataSource as DataSet;
DataRow _DataRow = _DataSet.Tables[0].NewRow();
_DataRow[0] = Date.Text;
_DataRow[1] = Author.Text;
_DataRow[2] = Source.Text;
_DataRow[3] = Title.Text;
_DataRow[4] = Summary.Text;
_DataRow[5] = NewsLink.Text;
_DataSet.Tables[0].Rows.Add(_DataRow);
_DataSet.AcceptChanges();
_DataSet.WriteXml(Server.MapPath("XMLFile.xml"));
BindData();
}[/code]
Thank you very much in advance.<br/>
Code:

View the full article
 
Back
Top