What Arduino are you using to get the data in buffer? 512 characters is 1/4 of the memory on most Arduinos.
Why do you need to send the entire array to the other Arduino? Get the data that the other one needs, and send just that data.
In any case, if buffer is a char array, rather than a byte array (that is, it does not contain embedded NULLs), then Serial.print(buffer); should send all the data in buffer, up to the first NULL, to the XBee to broadcast.
i have tried this and it hasnt worked
Something happened. You expected something to happen. All we now know is that those two somethings are not the same thing. You'll have to be far more descriptive than that.
Other things that might be helpful: What baud rate are you using to talk to the XBee? What baud rate are the XBees using to talk to each other? What kind of XBees are they? How often does the Canbus object get data? What does the rest of the code look like? What is the other XBee/Arduino doing?