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 

Newbie question

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





PostPosted: Sun May 06, 2007 10:49 pm    Post subject: Newbie question Reply with quote



New to XML and am getting an 'invalid character' message when I try to add a
child node based on a counter. Also, if you notice anything in my coding
that should be done differently please fell free to suggest a better way.

procedure TWrap.WriteToXML(parent:IXMLNode);
var
baseNode,Node,segNode:IXMLNode;
seg:TWrapSegment;
i:integer;
s:wideString;
begin
if parent.HasChildNodes then
baseNode:=parent.ChildNodes.FindNode('Wrap');
if baseNode<>nil then //delete old data if it exists
parent.ChildNodes.Delete('Wrap');
if segmentCount=0 then
exit;
BaseNode:=parent.AddChild('Wrap');
node:=baseNode.AddChild('Position');
node.NodeValue:=position;
node:=baseNode.AddChild('SegmentCount');
node.NodeValue:=segmentCount;
node:=baseNode.AddChild('Segments');
seg:=TWrapSegment.Create;
for i:=0 to segmentCount-1 do
begin
s:=intToStr(i);

this is where I get an 'invalid character' message

segNode:=node.AddChild(s);


seg:=segments[i];
seg.writeToXML(segNode);
end;
end;
Back to top
Rob Cooke
Guest





PostPosted: Mon May 07, 2007 1:09 am    Post subject: Re: Newbie question Reply with quote



On Sun, 6 May 2007 12:49:45 -0500, "RT" <ralph.tuttle (AT) visi (DOT) com> wrote:


Quote:
begin
s:=intToStr(i);

this is where I get an 'invalid character' message

segNode:=node.AddChild(s);

Element names can't begin with a number. You might instead use something like <segment index="1"
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.