Less efficient more robust code for mathML parser