title: Convert a PHP data structure into serialised XML
body: <p>I have the following array. I'm not even sure if that array is properly formatted. I am not even sure if my array is right. </p>
  
  <p>I want to convert the following array to a serialized XML using PHP. I am using attr tag for the attributes.</p>
  
  <p>Here is the array:</p>
  
  <pre><code>$data = Array(
  'name' =&gt; 'account',
  'attr' =&gt; Array(
      'id' =&gt; 123456
  ),
  'children' =&gt; Array(
      Array(
          'name' =&gt; 'name',
          'attr' =&gt; Array(),
          'children' =&gt; Array(
              'BBC'
          ),
      ),
      Array(
          'name' =&gt; 'monitors',
              'attr' =&gt; Array(),
          'children' =&gt; Array(
              Array(
                  'name' =&gt; 'monitor',
                  'attr' =&gt; Array(
                      'id' =&gt; 5235632
                  ),
                  'children' =&gt; Array(
                      Array(
                          'name' =&gt; 'url',
                          'attr' =&gt; Array(),
                          'children' =&gt; Array(
                              'http://www.bbc.co.uk/'
                          )
                      )
                  )
              ),
              Array(
                  'name' =&gt; 'monitor',
                  'attr' =&gt; Array(
                      'id' =&gt; 5235633
                  ),
                  'children' =&gt; Array(
                      Array(
                          'name' =&gt; 'url',
                          'attr' =&gt; Array(),
                          'children' =&gt; Array(
                              'http://www.bbc.co.uk/news'
                          )
                      )
                  )
              )
          )
      )
  )
  );
  </code></pre>