I'm soon going to be adding LEAP2A portfolio standard support to the portfolio API for Moodle 2.0, which raises the question of a consistent way to read/write XML (I only care about writing at the moment, but it's a good time to talk about both).
I would strongly advocate using the php5 builtin DOM functions, but that's not going to work, for example, for Backup/Restore because it's just too much to store in memory.
I kind of think it would be nice to have a consistent way of doing things, rather than a mix of Dom/XMLWriter/Simplewhatever/Smarty/Stringconcatenation, that we seem to have now.
* A DOMinatrix processor, for easy programming of XML things that we know are small (ie: environment.xml)
* A stream processor (with parser/callback for reading, and a "stream writing" mode that optionally validates); for unknown-size data...
I really wanted to be in today's meeting but could not- grr
I think that SimpleXML has become the defacto standard for reading (disclosure: I may be responsible for a few commits pushing that it that way ).
danp@dev:~/git/moodle$ git grep -i SimpleXML | wc -l 59
Eloys research in Development:Backup_2.0_-_Improve_XML_parsing which suggested the performance benefits of SimpleXML seems to suggest its a winner. Its also now in the php required extensions. (But its not really a huge deal to change it if there are some arguments against SimpleXML).
For writing I have no opinion as I know nothing about the benefits of the options. I do know i've seen bugs caused by the current inconsistent approach so agree that we shold standardise. (Reminder about a bug I created for this a while ago: MDL-13157 )
One limitation of SimpleXML is that it can't read comments, I believe. Nigel found this recently in Mahara, and had to load into DomDocument the SimpleXML object to get at the comment nodes.
I expect the comment is only added to question exports for the benefit of humans reading the file.