PHP has introduced a lot of new functions and classes with version 5. XMLWriter class is one of the new feature which can be used to write xml documents with PHP. Though there are tons of classes and functions to write xml format, XMLWriter class is poorly documented and doesn’t have too many examples. XML is widely used format next to JSON for most of the web based APIs. In this simple article let us touch the basics of PHP XMLWriter with a sample code. We will convert an associative array into XML document.