There’s one thing I was wondering about: why would you actually want to use the DOM/XML writing functions of PHP to generate XML? I mean: we’ve been generating HTML without specific functions for over 10 years, so why would we need a library to build a DOM tree instead of outputting XML directly??

Well… I got an answer at PHP Forum: it makes sure your XML is well formed when you spit it out!

Ha! I should have thought about it! :roll:

Now I’m wondering if I should be using this as a replacement for echo in order to make sure I generate well formed XHTML all the time… ;) I mean… generating a DOM tree would be overkill, but generating the XHTML code on the fly with XMLwriter might actually work out pretty well…

Hum…


Comments from long ago:

Comment from: Sylvain

Je pense que l’intéret de tels API (j’utilise actuellement DomDocument en PHP) n’est pas réellement de produire du XML mais bel et bien de le manipuler ou de le valider. Effectivement pour le produire qques “echo” associés à une classe d’introspection peuvent facilement faire l’affaire mais une fois produit, c’est important pour les deux partis en présence (en XML y a en général un client et un producteur) de pouvoir valider le document via une DTD en bonne et due forme. Celà évite maintes discutions entre les partis pour savoir d’où vient le problème (il suffit d’appliquer le validateur et on est fixé).

2005-11-25 11-55