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

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.

 private void ChangeValueofXMLNodeValue(string XMLPath,string SelectedSingleTag)


            XmlDocument doc = new XmlDocument();


            XmlNode root = doc.DocumentElement;

            XmlNode myNode = root.SelectSingleNode(SelectedSingleTag);

            myNode.Value  = textBox1.Text ;


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 ;


 myNode.InnerText  = textBox1.Text ;


Further Readings:


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