Delphi Xml question

Hello,

I need to add an "ntCData" type xml child to a sub-child.

My problem is that
1. XMLDoc.CreateNode((FieldByName('Product').AsString), ntCData, '');
allows it but it would put it to top level.

2.        With NodeProducts.AddChild('Product', -1) Do
         Begin
           Text := (FieldByName('Termek_Product').AsString);
         End;
... will put the node where I want, but it won't be ntCData type.

So I want to know how to put an "ntCData" type child under a chosen another child.

Thank you very much
starhuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
Try this:
Parentnode, NodeCData: IXMLNode;
....
NodeCData := XMLDoc.CreateNode(FieldByName('Product').AsString, ntCData, '');
Parentnode.ChildNodes.Add(NodeCData);
....

Open in new window

atul_parmarCommented:
Hi, try this.

Node := XMLDoc.CreateNode((FieldByName('Product').AsString), ntCData, '');
NodeProducts.ChildNodes.Add(Node);
starhuAuthor Commented:
Hello,

sinisav: I tried it and it correctly puts:
<![CDATA[BlackJacket]]>

but I need
<Name><![CDATA[BlackJacket]]></Name>

so I need to include in a <Name> tag
Sinisa VukSoftware architectCommented:
RootNode := XMLDoc.CreateNode('Name', ntElement, '');
ParentNode.ChildNodes.Add(RootNode);
NodeCData := XMLDoc.CreateNode('BlackJacket', ntCData, '');
RootNode.ChildNodes.Add(NodeCData);

Open in new window

... is this correct?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.