.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

removing a record from xml file

Posted By: softraj     Posted Date: February 27, 2010    Points:2   Category :C#
How to remove a record from xml file from c#.net application?

Responses
Author: Lalij Mer             
Posted Date: February 27, 2010     Points: 5   

show this code

string strXml = "<Samp><Batch><CRUISE>CRUISE</CRUISE><HNUM>HNUM</HNUM></Batch><Batch><CRUISE>11111</CRUISE><HNUM>2</HNUM></Batch></Samp>";
using(StringReader rd = new StringReader(strXml))
{
XmlTextReader rd1 = new XmlTextReader(rd);
using(DataSet ds = new DataSet())
{
XmlReadMode xmlRead = ds.ReadXml(rd1);
// Delete the first row
ds.Tables[0].Rows[0].Delete();
// overwrite the string
strXml = ds.GetXml();
}

}


http://forums.devshed.com/net-development-87/how-to-update-insert-delete-record-in-xml-file-606089.html

Please Check my answer if you help....
Thank You...

Lalit.
Author: Sagar Pardeshi             
Posted Date: March 02, 2010     Points: 5   

XmlNodeList newXMLNodes = XMLDom.SelectNodes("/PNode/Node1");
foreach(XmlNode newXMLNode in newXMLNodes)
if(newXMLNode.InnerText == "sree")
newXMLNode.ParentNode.RemoveChild(newXMLNode);
XMLDom.Save("Path of your XML file");
XMLDom = null;




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend