?
Solved

Modify an XML document

Posted on 2005-03-22
4
Medium Priority
?
192 Views
Last Modified: 2010-04-05
Okay, I have a program written in Delphi 6 that opens an XML document and can view content.  What I want to do is change the content, but I have no idea where to begin.  I've looked all over and cannot find a simple answer.  I'm hoping I don't have to use constructs, xsl or all that other crap.  It seems like if I'm getting a "node" I should just as simply be able to edit it.  Anyway, here's the XML file:

______________________________________

<?xml version="1.0"?>
<Users>
   <Character>
      <name>Scott</name>
      <password>test</password>
      <gender>male</gender>
   </Character>
   <Character>
      <name>Aeolus</name>
      <password>test</password>
      <gender>male</gender>
   </Character>
   <Character>
      <name>Bob</name>
      <password>pwforbob</password>
      <gender>male</gender>
   </Character>
   <Character>
      <name>Fred</name>
      <password>fredspw</password>
      <gender>Male</gender>
   </Character>
</Users>
___________________________________

and here's the code:
___________________________________

procedure TForm1.FormCreate(Sender: TObject);
begin
   XMLDoc.LoadFromFile('c:\project\server\users.xml');
   XMLDoc.Active := true;

   StartItemNode := XMLDoc.DocumentElement.ChildNodes.FindNode('Character');
   CharNode := StartItemNode;
   repeat
    ListBox1.AddItem(CharNode.ChildNodes['name'].Text,nil);
    CharNode := CharNode.NextSibling;
   until CharNode = nil;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   CharNode := StartItemNode;
   repeat
    if CharNode.ChildNodes['name'].Text = TListBox(Listbox1).Items[TListBox(Listbox1).ItemIndex] then
    ShowMessage (CharNode.ChildNodes['password'].Text);
    CharNode := CharNode.NextSibling;
   until CharNode = nil;
end;

_________________________________

As you can see, it gets all the <name>'s and pupulates a listbox.  Then, if you select one of the names and click "show password" it shows you the <password> from that <name>.  What I want to do is add an EditBox and another button and be able to change the <password> for the selected <name>.  I have no idea where to begin.
0
Comment
Question by:Cerixus
[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
  • 2
4 Comments
 
LVL 1

Author Comment

by:Cerixus
ID: 13607701
Holy crap, it's like a billion times easier than I expected...

All I did was this:

      CharNode.ChildNodes['password'].Text := Edit1.Text;
      XMLDoc.SaveToFile('c:\project\server\users.xml');

I'm diggint XML...  Sorry for the pointless question, but maybe it will help someone else :)
0
 
LVL 1

Author Comment

by:Cerixus
ID: 13607703
*digging :)

Please close this question.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 13609041
You need to post a question in the Community Support forum to request this question be closed PAQ with points refund.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 14071554
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

771 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