예제 #1
0
        </books>    
*/
$x = new XMLegant();
$book_data = new XMLegant();
for ($i = 0; $i < 5; $i++) {
    $book_data->title = "Title {$i}";
    $book_data->author = "Author {$i}";
    $book_data->isbn = "isbn {$i}";
    $x->books->book[] = $book_data;
}
/*
    Or using chaining
*/
$x = new XMLegant();
for ($i = 0; $i < 5; $i++) {
    $x->books->book[] = XMLegant::Create()->title("Title {$i}")->author("Author {$i}")->isbn("isbn {$i}");
}
/*
    Or, using even more chaining...
*/
$x = new XMLegant();
for ($i = 0; $i < 5; $i++) {
    $x->books->book()->title("Title {$i}")->author("Author {$i}")->isbn("isbn {$i}");
}
/*
    Create one element. This creates:
        <a>
            <b>f</b>
        </a>   
    It does not create: 
        
 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)}");
 }