• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

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
0
starhu
Asked:
starhu
  • 2
1 Solution
 
Sinisa VukCommented:
Try this:
Parentnode, NodeCData: IXMLNode;
....
NodeCData := XMLDoc.CreateNode(FieldByName('Product').AsString, ntCData, '');
Parentnode.ChildNodes.Add(NodeCData);
....

Open in new window

0
 
atul_parmarCommented:
Hi, try this.

Node := XMLDoc.CreateNode((FieldByName('Product').AsString), ntCData, '');
NodeProducts.ChildNodes.Add(Node);
0
 
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
0
 
Sinisa VukCommented:
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?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now