Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
Generalclose button on control box of form Pin
visiontec11-Feb-04 11:34
visiontec11-Feb-04 11:34 
GeneralRe: close button on control box of form Pin
Heath Stewart11-Feb-04 12:18
protectorHeath Stewart11-Feb-04 12:18 
GeneralOpinions needed on Win Form Design Pin
MrJJKoolJ11-Feb-04 11:29
MrJJKoolJ11-Feb-04 11:29 
GeneralRe: Opinions needed on Win Form Design Pin
Heath Stewart11-Feb-04 12:15
protectorHeath Stewart11-Feb-04 12:15 
GeneralRe: Opinions needed on Win Form Design Pin
MrJJKoolJ11-Feb-04 14:18
MrJJKoolJ11-Feb-04 14:18 
GeneralRe: Opinions needed on Win Form Design Pin
Heath Stewart12-Feb-04 3:26
protectorHeath Stewart12-Feb-04 3:26 
GeneralSetting Properties through .Net Remoting Pin
Brian Rogan11-Feb-04 11:09
Brian Rogan11-Feb-04 11:09 
Generalproblem with XmlDocument Pin
visiontec11-Feb-04 10:50
visiontec11-Feb-04 10:50 
Hi there

I am having problems using the XmlDocument class when editing an xml file.
This is what my xml file looks like :

<VTs_InfoKeeper>
<WebPwds>
<WebPwd>
<website>Code Project</website>
<uid>visiontec</uid>
<pwd>somefakepwd</pwd>
<description>gr8 website. c# fourms and more.</description>
</WebPwd>
</WebPwds>
</VTs_InfoKeeper>

This is the way i am using XmlDocument :

private bool SaveXml( string WebsiteName,
string UserId,
string Pwd,
string Description )
{
XmlDocument doc = new XmlDocument();
try
{
doc.Load("vtinfokeeper.xml");
}
catch(Exception)
{
return false;
}

XmlElement newWebPwd = doc.CreateElement("WebPwd");

XmlElement newWebsite = doc.CreateElement("website");
newWebsite.InnerText = WebsiteName;
newWebPwd.AppendChild(newWebsite);

XmlElement newUID = doc.CreateElement("uid");
newUID.InnerText = UserId;
newWebPwd.AppendChild(newUID);

XmlElement newPwd = doc.CreateElement("pwd");
newPwd.InnerText = Pwd;
newWebPwd.AppendChild(newPwd);

XmlElement newDescr = doc.CreateElement("description");
newDescr.InnerText = Description;
newWebPwd.AppendChild(newDescr);

doc.DocumentElement.AppendChild(newWebPwd);

XmlTextWriter tr = new XmlTextWriter("vtinfokeeper.xml",null);
tr.Formatting = Formatting.Indented;
try
{
doc.WriteContentTo(tr);
}
catch(Exception)
{
return false;
}

tr.Close();
return true;
}

Now when i run the above code i get this result :


<VTs_InfoKeeper>
<WebPwds>
<WebPwd>
<website>Code Project</website>
<uid>visiontec</uid>
<pwd>vtlives</pwd>
<description>gr8 website. c# fourms and more.</description>
</WebPwd>
</WebPwds>
<WebPwd>
<website>somwwebsite</website>
<uid>somewuid</uid>
<pwd>somwpwd</pwd>
<description>somedescr</description>
</WebPwd>
</VTs_InfoKeeper>

Whereas i wish to accomplish the result below :

<VTs_InfoKeeper>
<WebPwds>
<WebPwd>
<website>Code Project</website>
<uid>visiontec</uid>
<pwd>vtlives</pwd>
<description>gr8 website. c# fourms and more.</description>
</WebPwd>
<WebPwd>
<website>somwwebsite</website>
<uid>somewuid</uid>
<pwd>somwpwd</pwd>
<description>somedescr</description>
</WebPwd>
</WebPwds>
</VTs_InfoKeeper>


What am i doing wrong?
Can anyone plz point out the correct way that i should use
the XmlDocument class to get my desired result.

And as u can see that the pwd field is in clear text,
which way of encryption should i use to secure the pwds?

VisionTec
GeneralRe: problem with XmlDocument Pin
Kentamanos11-Feb-04 11:01
Kentamanos11-Feb-04 11:01 
QuestionIs anything wrong with this? Pin
profoundwhispers11-Feb-04 10:40
profoundwhispers11-Feb-04 10:40 
AnswerRe: Is anything wrong with this? Pin
Heath Stewart11-Feb-04 12:08
protectorHeath Stewart11-Feb-04 12:08 
GeneralDatabinding to combobox Pin
Anonymous11-Feb-04 10:34
Anonymous11-Feb-04 10:34 
GeneralRe: Databinding to combobox Pin
Heath Stewart11-Feb-04 12:00
protectorHeath Stewart11-Feb-04 12:00 
Generalmanaging Deletes and Backspaces Pin
obelisk2911-Feb-04 10:19
obelisk2911-Feb-04 10:19 
GeneralRe: managing Deletes and Backspaces Pin
Heath Stewart11-Feb-04 11:57
protectorHeath Stewart11-Feb-04 11:57 
Generalmanaged c++ class that inherits from unmanaged c++ Pin
godzooky11-Feb-04 8:30
godzooky11-Feb-04 8:30 
GeneralRe: managed c++ class that inherits from unmanaged c++ Pin
Heath Stewart11-Feb-04 9:47
protectorHeath Stewart11-Feb-04 9:47 
GeneralRe: managed c++ class that inherits from unmanaged c++ Pin
godzooky11-Feb-04 9:50
godzooky11-Feb-04 9:50 
GeneralRe: managed c++ class that inherits from unmanaged c++ Pin
Heath Stewart11-Feb-04 9:52
protectorHeath Stewart11-Feb-04 9:52 
GeneralRe: managed c++ class that inherits from unmanaged c++ Pin
godzooky11-Feb-04 10:07
godzooky11-Feb-04 10:07 
GeneralRe: managed c++ class that inherits from unmanaged c++ Pin
Heath Stewart11-Feb-04 10:10
protectorHeath Stewart11-Feb-04 10:10 
GeneralMouse Button &gt; keystroke Pin
Spanky311-Feb-04 8:04
Spanky311-Feb-04 8:04 
GeneralRe: Mouse Button &gt; keystroke Pin
Kentamanos11-Feb-04 8:15
Kentamanos11-Feb-04 8:15 
GeneralRe: Mouse Button &gt; keystroke Pin
Daniel Turini11-Feb-04 8:16
Daniel Turini11-Feb-04 8:16 
GeneralRe: Mouse Button &gt; keystroke Pin
Spanky311-Feb-04 8:28
Spanky311-Feb-04 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.