question about DOM level 1 ordering of children

Apologies if this is an FAQ - I've searched the archive and can't find
anything directly relevant, and the spec also.

I'm wondering about guarantees of ordering of child elements. I'm involved
in an XML application for which the ordering of elements is currently
assumed to be important. I'd like to verify that the ordering of elements
is guaranteed to be preserved in the DOM.

I'll give an example. I have an element specified for which the content
model is

<!ELEMENT a (p,p,p)>

and then an instance of this element as follows 


Say I have a very similar element with content model

<!ELEMENT b (p*)>

and a document containing


My question is this: for which of the above elements is it guaranteed, for
any compliant DOM implementation, that when I look at childNodes for the
parent element, the first child I get back will be the first child
encountered in a linear run-through of the textual implementation of the
XML document?

I can't find any guarantee of this property, particularly if the content
model doesn't specify a sequence, in the DOM spec. Currently our design
places some significance on the ordering of child elements, and really I'm
trying to find out if we can rely on this correspondence.

NB I haven't looked at DOM level 2, since I'm only dealing with level 1
processors at the moment.

Chris Harris

        Visit our Internet site at

Any views expressed in this message are those of  the  individual
sender,  except  where  the sender specifically states them to be
the views of Reuters Ltd.

Received on Tuesday, 9 November 1999 16:07:36 UTC