BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XMLDocument question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi XML
View previous topic :: View next topic  
Author Message
Steve
Guest





PostPosted: Mon Oct 16, 2006 10:15 pm    Post subject: XMLDocument question Reply with quote



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





PostPosted: Mon Oct 16, 2006 10:15 pm    Post subject: Re: XMLDocument question Reply with quote



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





PostPosted: Mon Oct 16, 2006 11:50 pm    Post subject: Re: XMLDocument question Reply with quote



"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





PostPosted: Tue Oct 17, 2006 3:00 am    Post subject: Re: XMLDocument question Reply with quote

Thanks Matthias and Remy for your replies, I do appreciate your help.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi XML All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.