Below is the code that I am running
I think "running" is not the right word, because the code you have shown will not even compile, let alone run.
In this part of your code
type
TForm9 = class(TForm)
[...]
procedure AddSimpleElement(doc : DOMDocument40; parent : IXMLDOMElement; name, value : String);
[...]
you declare AddSimpleElement
as a method of your TForm9 class, but in this code
procedure AddSimpleElement(doc : DOMDocument40; parent : IXMLDOMElement; name, value : String);
var
newElem : IXMLDOMElement;
begin
newElem := doc.createElement(name);
newElem.text := value;
parent.appendChild(newElem);
end
you don't define the implementation of TForm9's AddSimpleElement
, contrary to what you might be thinking. Instead you declare a stand-alone procedure AddSimpleElement which has no relation to TForm9 at all. Change your code to
procedure TForm9.AddSimpleElement(doc : DOMDocument40; parent : IXMLDOMElement; name, value : String);
var
newElem : IXMLDOMElement;
begin
[...]
and you will improve the chances of your code compiling. There may still be other problems, of course.
Btw, this is the sort of mistake it is easy to make, especially at the end of a long day. You could have avoided it by using the IDE's "Class completion" assistance. After you type
procedure AddSimpleElement(doc : DOMDocument40; parent : IXMLDOMElement; name, value : String);
in TForm9's type declaration, if you press Ctrl-Shift-C, then the IDE will generate the (empty) implementation of the method and move the cursor to it.
Btw, if you don't mind me saying, the dumb part of your q was including the completely unhelpful screen-shot, but not mentioning in your q the exact text of the error message the compiler would have produced when you attempted to compile your code. In this case, it was obvious at a glance what one glaring error with your code is, but you really should try to provide the best information you can when asking for help here.