XMLSocket

Task: real time multiplayer game + chat…the server is ready with chatrooms, the messages show up nice so is working.
The game itself need 4-5 arrays to pass from one player to other, in xml format, becouse this way I can handle them in the most efficient way.
To separate the arrays from the simple chat text I tyred to filter the messages on the firstChild.nodeName, if is recognized than is a real xml , otherwise is chat text, but the XMLSocket.onData or XMLSocket.onXML functions I cant convince to recognize the incoming string as xml, when I redirect to an output textfield is looking ok the string so the xml formating isn’t a problem.

So my questions are:
-how can use XMLSocket.onData or XMLSocket.onXML to assign the incoming message to an xmlObject , something in this manner(but this isnt working):

XMLSocket.onData = function(msg){
   myXML = new XML()
   myXML  = msg // or whatever code need here
}

I cant find an evoluated tutorial on this question(all of them are only for a simple chat, no one is using more than a redirect to a textfield), so if somebody know one or have some code snippets… help pls