How to change or replace the xml node value and attribute value/
xml node in the document, want to change node value and attribute vale of the node in the word document
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Yadlapalli SrikanthPosted Jan 30, 2012, 1:42 AM
private void updateDocument()
{
StringBuilder sb = new StringBuilder();
string strFileName = "Testimonial2.xml";
string pathStr = Server.MapPath("");
if (Directory.Exists(pathStr) == false)
{
Directory.CreateDirectory(pathStr);
}
string direcPath = pathStr + "\\Testimonial2.xml";
if (File.Exists(direcPath) == true)
{
XmlDocument doc;
try
{
doc = new XmlDocument();
doc.Load(direcPath);
doc.Save(direcPath);
}
catch (Exception ex)
{
}
finally
{
}
try
{
doc = new XmlDocument();
doc.Load(direcPath);
XmlNode oldChild = doc.SelectSingleNode("Poems/Poems[content = '" + txtcontenthidden.Text + "']");
foreach (XmlNode node1 in oldChild.ChildNodes[0])
{
oldChild.ChildNodes[0].InnerText = txtContent.Text;
oldChild.ChildNodes[3].InnerText = DateTime.Now.ToShortDateString();
}
doc.Save(direcPath);
bindTest();
lblerror.Text = "
txtContent.Text = "";
btnContent.Text = "Add Testimonial";
btnContent.CommandName ="Add Testimonial";
btndelete.Visible = false;
}
catch (Exception ex)
{
throw ex;
}
finally
{
// fsReadXml.Close();
}
}
}