Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML: child and parent with the same name

Tags:

xml

In valid XML, is it possible to have children with the same name as their parent? For example:

<parent>
    <child>
    </child>
    <parent>
    </parent>
</parent>

Thank you.

like image 233
user42155 Avatar asked Nov 25 '11 16:11

user42155


2 Answers

There is nothing aside from a specific DTD or XSD that would prevent this.

like image 128
Matt Ball Avatar answered Sep 28 '22 18:09

Matt Ball


Yes, this is even valid (sometimes) in XHTML. for example the following is valid XHTML (within a page body):

<div>
  <div>
  </div>
</div>
like image 30
Tom Carver Avatar answered Sep 28 '22 17:09

Tom Carver