Need to start at the end of the children instead of the beginning. nextSibling correctly calls firstChild.
Could you provide a test case?
It does seem obvious from code inspection that this is broken, and replacing firstChild with lastChild should be all it takes to fix it; the test case is going to be the hardest part.
Created attachment 61324 [details] Test case
Created attachment 61563 [details] Patch
Committed r63365: <http://trac.webkit.org/changeset/63365>
Mass moving XML DOM bugs to the "DOM" Component.