.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 >> Code Snippets >> Bugs & Resolutions >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Cannot set a value on node type 'Element in XML.

Posted By:Narayanan       Posted Date: December 13, 2012    Points: 40    Category: Bugs & Resolutions    URL: http://www.dotnetspark.com  

Here i give a Solution for Cannot set a value on node type 'Element' using XML.
 

Code:
 private void ChangeValueofXMLNodeValue(string XMLPath,string SelectedSingleTag)

        {

            XmlDocument doc = new XmlDocument();

            doc.Load(XMLPath);

            XmlNode root = doc.DocumentElement;

            XmlNode myNode = root.SelectSingleNode(SelectedSingleTag);

            myNode.Value  = textBox1.Text ;

            doc.Save(XMLPath);

        }
Suppose you run the above Code. You will get the Error:Cannot set a value on node type 'Element'
How to Solve?

 myNode.Value  = textBox1.Text ;

change

 myNode.InnerText  = textBox1.Text ;



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

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