Example #1
0
 function __call($name, $args)
 {
     $child = $this->addChild($name);
     switch (count($args)) {
         case 0:
             return $child;
         case 1:
             XMLegant::SetChild($child, $args[0]);
             break;
         case 2:
             $child->offsetSet($args[0], $args[1]);
             break;
     }
     return $this;
 }
Example #2
0
            <b>c</b>
            <b>d</b>
            <b>e</b>
            <b>f</b>
        </a>   
*/
$x = new XMLegant();
$x->a->b = 'c';
$x->a->b = 'd';
$x->a->b = 'e';
$x->a->b = 'f';
/*
    The following will create:
            
        <a>
            <b>c</b>
            <b>d</b>
            <b>e</b>
            <b>f</b>
        </a>       
*/
$x = new XMLegant();
$x->a->b[] = 'c';
$x->a->b[] = 'd';
$x->a->b[] = 'e';
$x->a->b[] = 'f';
/*
    Or, using method chaining...
*/
$x = new XMLegant();
$x->a()->b('c')->b('d')->b('e')->b('f');
 function test_startTag()
 {
     $books = XMLegant::Create('books');
     $books->book()->author("some author1")->title("some title1");
     $books->book()->author("some author2")->title("some title2");
     assert("\$books->toXML(FALSE) == '<books><book><author>some author1</author><title>some title1</title></book><book><author>some author2</author><title>some title2</title></book></books>';//{\$books->toXML(FALSE)}");
 }