Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML root node with slash... unexplained?

Tags:

xml

root

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.

like image 920
Tony The Lion Avatar asked Sep 12 '25 10:09

Tony The Lion


2 Answers

<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.

like image 191
kennytm Avatar answered Sep 13 '25 23:09

kennytm


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

like image 41
Torbjörn Hansson Avatar answered Sep 14 '25 00:09

Torbjörn Hansson