This works fine for me:
define temp-table ttCust no-undo like customer.
for each customer no-lock where custNum = 1:
create ttCust.
buffer-copy customer to ttCust.
end.
temp-table ttCust:write-xml( "file", "cust.xml", true ).
You cannot directly write a db table to XML. You have to copy the records that you want into a temp-table first.