<message to="foo@gmail.com" type="chat">
<x xmlns="jabber:x:event">
<composing />
</x>
<composing xmlns="http://jabber.org/protocol/chatstates" />
</message>
- if on first keypress, we are trying to erase/delete a letter:
<message to="foo@gmail.com" type="chat">
<x xmlns="jabber:x:event" />
<active xmlns="http://jabber.org/protocol/chatstates" />
</message>
- if receiving a message:
<message to="foo@gmail.com" type="chat">
<x xmlns="jabber:x:event">
<composing />
</x>
<active xmlns="http://jabber.org/protocol/chatstates" />
<body>foo is not bar
<html xmlns="http://jabber.org/protocol/xhtml-im" />
<body xmlns="http://www.w3.org/1999/xhtml">foo is not bar
</html>
</message>
Here are some ways to parse the values (according to E4X specification):
============================================================
stanza = <message to="foo@gmail.com" type="chat">
<x xmlns="jabber:x:event">
<composing />
</x>
<active xmlns="http://jabber.org/protocol/chatstates" />
<body>foo is not bar</body>
<html xmlns="http://jabber.org/protocol/xhtml-im" />
<body xmlns="http://www.w3.org/1999/xhtml">foo is not bar</body>
</html>
</message>
stanza.body = "foo is not bar"
stanza.@to = "foo@gmail.com"
but, to get the namespace (xmlns) values, its a little bit different:
var ns = 'jabber:x:event'; //declare a var to hold the required namespace
if(stanza.ns::x != undefined) {
// ok, there is an <x xmlns="jabber:x:event" />
} else {
// no
}
alert(stanza.ns::x.namespace()); //display the namespace in an alert box
so for getting the xmlns value, the general term would be:
stanza.[NAMESPACE_VAR]::[TAG_NAME].namespace();
Thanks to Bard for the help on these codes. Original source is can be found in the forum. If I found a reliable E4X documentation, I'll post it here.
No comments:
Post a Comment