13 1 ....">
C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » XML »

How to retrive an value from xml for a particluar node and again update the xml


Posted Date: 04 Nov 2009      Posted By: kumar      Member Level: Gold     Points: 1   Responses: 1



<?xml version="1.0"?>
<Image>
<Overview>13</Overview>
<Gallery1>1</Gallery1>
<Gallery2>4</Gallery2>
<Gallery3>6</Gallery3>
<Gallery4>1</Gallery4>
</Image>



hi this is my xml file i have an dropdown value with values [gallery1, gallery2, gallery3 so on . if user select an gallery2 and types in the text box as = 5 and clicks ok button then i need to load my above xml file and check what is gallery value we need to update but first we need to get the value from xml her i am trying to update galery2 so before i need get gallery2 value =4
then add the new value with old value{5+4=9) and then save . so now gallery2 will contain value as 9

result

<?xml version="1.0"?>
<Image>
<Overview>13</Overview>
<Gallery1>1</Gallery1>
**<Gallery2>9</Gallery2>**
<Gallery3>6</Gallery3>
<Gallery4>1</Gallery4>
</Image>





Responses

Author: Lakhan Pal    04 Nov 2009Member Level: DiamondRating: 3 out of 53 out of 53 out of 5     Points: 3

Hi -

You can check this Code:

XmlDocument xDoc = new XmlDocument();
xDoc.Load(Server.MapPath("sample1.xml"));
XmlNodeList xmlList= xDoc.GetElementsByTagName("Gallery2");
for (Int16 iCount = 0; iCount < xmlList.Count; iCount++)
{
xmlList.Item(iCount).InnerText = textbox1.Text.Trim();
}
xDoc.Save(Server.MapPath("sample1.xml"));


Please rate this answer if it helped you.
Thanks & Regards
Lakhan Pal Garg
Free Code Snippets



Post Reply
You must Sign In to post a response.
Next : Display only the Name tag in the Treeview-C# code
Previous : Please provide urgent fix on XML error while passing xml in Websevice.
Return to Discussion Forum
Post New Message
Category: XML

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use