 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Steve Guest
|
Posted: Mon Oct 16, 2006 10:15 pm Post subject: XMLDocument question |
|
|
Hi,
I am trying to save data to an XML file using the following code:
var
UHead, UVersion : IXMLNode;
name:String;
begin
name := 'xmltesting.xml';
XMLDocument1.Active := true;
XMLDocument1.Version:='1.0';
XMLDocument1.Encoding:='ISO-8859-1';
XMLDocument1.DocumentElement := XMLDocument1.CreateElement('infofile','');
UHead := XMLDocument1.DocumentElement.AddChild('head','');
UVersion:= UHead.AddChild('version', '');
UVersion.Attributes['version']:=Edit1.Text;
XMLDocument1.SaveToFile(name);
XMLDocument1.XML.Clear;
end;
Now the problem I am facing is that the output XML file is in the following
format:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<infofile>
<head>
<version version="123DED" />
</head>
</infofile>
Although the format I am looking for is to be like this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<infofile>
<head>
<version>123DED</version>
</head>
</infofile>
So can someone please help me and tell me how I can make the output XML file
formatted just like that above?
Thanks in advance for your time and efforts.
Best Regards |
|
| Back to top |
|
 |
matthias muntwiler Guest
|
Posted: Mon Oct 16, 2006 10:15 pm Post subject: Re: XMLDocument question |
|
|
Steve wrote:
| Quote: | I am trying to save data to an XML file using the following code:
var
UHead, UVersion : IXMLNode;
name:String;
begin
name := 'xmltesting.xml';
XMLDocument1.Active := true;
XMLDocument1.Version:='1.0';
XMLDocument1.Encoding:='ISO-8859-1';
XMLDocument1.DocumentElement := XMLDocument1.CreateElement('infofile','');
UHead := XMLDocument1.DocumentElement.AddChild('head','');
UVersion:= UHead.AddChild('version', '');
UVersion.Attributes['version']:=Edit1.Text;
XMLDocument1.SaveToFile(name);
XMLDocument1.XML.Clear;
end;
[...]
Although the format I am looking for is to be like this:
?xml version="1.0" encoding="ISO-8859-1" ?
infofile
head
version>123DED</version
/head
/infofile
So can someone please help me and tell me how I can make the output XML file
formatted just like that above?
|
UVersion.Text := Edit1.Text;
--matthias |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Oct 16, 2006 11:50 pm Post subject: Re: XMLDocument question |
|
|
"Steve" <steve.no.spam (AT) gmail (DOT) com> wrote in message
news:4533936e (AT) newsgroups (DOT) borland.com...
| Quote: | Now the problem I am facing is that the output XML file is in the
following |
<snip>
As it should be, because that is what you are explitically telling it to do.
| Quote: | Although the format I am looking for is to be like this:
|
You need to change this line:
UVersion.Attributes['version']:=Edit1.Text;
To this:
UVersion.Text := Edit1.Text;
Gambit |
|
| Back to top |
|
 |
Steve Guest
|
Posted: Tue Oct 17, 2006 3:00 am Post subject: Re: XMLDocument question |
|
|
| Thanks Matthias and Remy for your replies, I do appreciate your help. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|