title: generating XML in rails
body: <p>I created a controller having an action:</p>
  
  <pre><code>def gen_books_xml
    @books = Book.find(:all, :conditions =&gt; {:owner_id =&gt; 1})
    respond_to do |format|
      format.xml { render :xml =&gt; @books.to_xml(:root =&gt; "Books", :skip_types=&gt;true) }
    end
  end
  </code></pre>
  
  <p>How could I implement the to_xml method in the Book model sa that it can generate the following format?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Books&gt;
    &lt;Owner&gt;1&lt;/Owner&gt;
    &lt;Book&gt;&lt;title&gt;some title&lt;/title&gt;&lt;/Book&gt;
    &lt;Book&gt;&lt;title&gt;some title&lt;/title&gt;&lt;/Book&gt;
    &lt;Book&gt;&lt;title&gt;some title&lt;/title&gt;&lt;/Book&gt;
    ...
  &lt;/Books&gt;
  </code></pre>
  
  <p>where there is only 1 Owner element and many Book elements</p>
  
  <p>I can only output the Book elements but cannot output the one Owner in the same level of Books. Please HELP!!!</p>