tags:

views:

45

answers:

2

Why would you have a rootnode in an XML document that looks like this:

<return/>

Why is that slash there? I have never seen an XML document like this, however in an application I am debugging, a root node looking like this one is created, and appending any child nodes seems to be failing.

Removing the slash crashes the program.

It uses MSXML DOM in C++ under windows.

+8  A: 

<foo/> is equivalent to <foo></foo>. This is known as an empty element. Without the ending /, the open tag will not have a corresponding closing tag, and thus an error.

KennyTM
+1  A: 

That is the root node of the xml document and it has no child elements. That's why it has no ending tag.

Torbjörn Hansson
Actually it does have a closing tag. This notation is said to be `self closing`, so the closing tag is implied, but it is there.
Philip Smith