Issue building an XML document using TXMLDocument

后端 未结 3 343
清歌不尽
清歌不尽 2021-01-12 06:44

I\'m new to delphi and now I have to read create an xml. my code is the following:

function foo.createXMLDocument(): TXMLDocument;
var
  res: TXMLDocument;
          


        
3条回答
  •  暖寄归人
    2021-01-12 07:08

    The Delphi Help of TXMLDocument.AddChild method says (at the bottom):

    Note: Do not call AddChild to add a child to the document element of this document. When adding data to the XML document, use the AddChild method of the document element or of the node in the hierarchy that should be the parent of the new node.

    And this is what you are doing right? :-)

    Here is an introduction article about Delphi XML Document Programming and shows how you can work with the TXMLDocument.DocumentElement property instead of your definition of the rootnode variable in your code.

提交回复
热议问题