I started working on an experimental project tonight. I’ve realized that I need to determine if a group of selected nodes are self closing or not.
For example, suppose I query the dom and get this collection of nodes:
<br/><br/><p></p><div></div></br/>
Is there a property on the elements that can determine which are which?
Moreover, rather than filter on specific html elements (oh, if this were the only limitations), suppose that I am parsing an XML document that can contain arbitrarily named tags.
XML does not differentiate self closing tags from empty tags, so
<p />and<p></p>are identical, as far as XML is concerned.Some XML parsers will parse all such structures to be
<p />some will parse them all to<p></p>and some will just leave them as they are.I would say there is no foolproof way to do this – you will have to specifically test on your browser of choice, see what exactly is returned and if you can work with that (searching for
/>for example).