Solved

Updating XML

Posted on 2009-05-13
1
204 Views
Last Modified: 2012-05-06
I have several text boxes which I'm using to update an XML document (customers field, with title, initial, firstname, surname).  So anyway I'm trying to minimise code by not having several lines like this:
node.Attributes.GetNamedItem("firstname").Value = txtFirstname1.Text;
node.Attributes.GetNamedItem("firstname").Value = txtFirstname2.Text;
node.Attributes.GetNamedItem("firstname").Value = txtFirstname3.Text;
node.Attributes.GetNamedItem("firstname").Value = txtFirstname4.Text;
etc

What would be the best way to keep code small and tight, and update each attribute with the value in the text box?  I thought of using a foreach(Control... but what would I do then?  I can't really guarantee the order (as far as I know) that they would be added to a list, and would be unable to tell which customer it is.  

All help is greatly appreciated.
0
Comment
Question by:angus_young_acdc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
ToddBeaulieu earned 500 total points
ID: 24377644
w/o creating a test project to get the exact syntax down, I'll take a stab...

If you assign a Tag to each control, setting it's value to be the name of the Xml attribute, you could enumerate all controls and if a Tag is present, set the corresponding attribute's value. I don't know off the top of my head the correct approach to getting/setting the attribute, but it might be along the lines of attempting to get it, and if found, set it. If not found, create it/set it.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question