Example #1
0
    public function testIndentation()
    {
        $builder = new Mad_Support_Builder(array('indent' => 2));
        $builder->instruct();
        $tag = $builder->startTag('user', '');
        $tag->tag('age', 28, array('type' => 'integer'));
        $tag->end();
        $expected = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<user>
  <age type="integer">28</age>
</user>

XML;
        $this->assertEquals($expected, $builder->__toString());
    }
Example #2
0
 /**
  * Convert errors to xml
  * 
  * @return  string
  */
 public function toXml($options = array())
 {
     if (!isset($options['root'])) {
         $options['root'] = 'errors';
     }
     if (!isset($options['indent'])) {
         $options['indent'] = 2;
     }
     if (!empty($options['builder'])) {
         $builder = $options['builder'];
     } else {
         $builder = new Mad_Support_Builder(array('indent' => $options['indent']));
     }
     if (empty($options['skipInstruct'])) {
         $builder->instruct();
     }
     $tag = $builder->startTag($options['root']);
     foreach ($this->fullMessages() as $msg) {
         $tag->tag('error', $msg);
     }
     $tag->end();
     return $builder->__toString();
 }