Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET XML


1
arvind
123456
false


2
tarun
123
false

Posted 27-Apr-13 0:57am
Edited 27-Apr-13 1:31am
v4
Comments
ThePhantomUpvoter at 27-Apr-13 5:59am
   
This is a code dump, not a question or a description of a problem.
Rohit 2012 at 27-Apr-13 6:03am
   
this code is not worling thats why m asking .................
ThePhantomUpvoter at 27-Apr-13 6:23am
   
You need to tell us what "not working" means. How are we supposed to know what it means? did you debug it at all? What did you find? Get any errors? What errors? Did you run the code and your house burned down? Do you call your mechanic on the phone and tell him "car broke" and expect that he can tell you exactly what is wrong with your car?
Rohit 2012 at 27-Apr-13 6:29am
   
actaually i m trying too many things bt can't able to change the password .plz provide me other asp.net code
Rohit 2012 at 27-Apr-13 6:30am
   
My XML FIle is as below
 
<employee>
<employee>
<id>1</id>
<userid>arvind</userid>
<Password>123456</Password>
<isactive>false</isactive>
</employee>
<employee>
<id>2</id>
<userid>tarun</userid>
<Password>123</Password>
<isactive>false</isactive>
</employee>
</employee>

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can change the password element of any employee like this:
 
string xmlstr = @"<employees>
  <employee>
    <id>1</id>
    <userid>arvind</userid>
    <Password>123456</Password>
    <isactive>false</isactive>
  </employee>
  <employee>
    <id>2</id>
    <userid>tarun</userid>
    <Password>123</Password>
    <isactive>false</isactive>
  </employee>
</employees>";
 
XmlDocument document = new XmlDocument();
document.LoadXml(xmlstr);
 
XmlNode employee = document.SelectSingleNode("//employee[id='2']");
employee["Password"].InnerText = "newpass";
 
Please note followings:
- I suppose you will have to load from file (use proper method)
- I have selected the Employee with ID=2
- I have used employees as root element. Yous root element was also employee.
- This was an in-memory update, you will probably have to save the result
  Permalink  
Comments
Rohit 2012 at 29-Apr-13 2:50am
   
error occurs "Data at the root level is invalid".
Zoltán Zörgő at 29-Apr-13 15:24pm
   
As I mentioned in my answer: use employees as root element!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 27 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100