I'm having trouble trying to build up an xml file.

basically I'm looping thru an array and I want to append items to a node based on a value.

so if i have an array like:

PHP Code:
 my_array = [["sam""string 1"], ["sam""string 2"], ["joe""string 1"]] 
I want to end up with xml like:

<person ="sam">
<dialog>string 1</dialog>
<dialog>string 2</dialog>
<person ="joe">
<dialog>string 1</dialog>

Here's my attempt:
PHP Code:
  people_listing_xml ="<people>\n"
people_xml Builder::XmlMarkup.new(:target => people_listing_xml, :indent => 1)
//inside the loop
people_xml.chat "person"=>person do
people_xml.dialog dialog
<< "</people>\n" 
thanks for any help