3 messages in com.googlegroups.google-talk-openRe: XmlElement problem
FromSent OnAttachments
pete...@gmail.com23 Jul 2007 10:05 
pete...@gmail.com23 Jul 2007 10:31 
siva24 Jul 2007 23:36 
Subject:Re: XmlElement problem
From:pete...@gmail.com (pete@gmail.com)
Date:07/23/2007 10:31:10 AM
List:com.googlegroups.google-talk-open

I solved the problem, using FirstElement() instead of FirstChild().

Hi,

I'm working on a libjingle application, and I've got some problem with xml handling. I tried to make a XmppTask class which handles message stanzas. I found an example
here:http://groups.google.com/group/google-talk-open/browse_thread/thread/...

The task works fine until it gets to ProcessStart(). I'm sure that the message arrives fine to the host. And I put it in the MessageQueue in HandleStanza().

int TextSessionClient::ProcessStart() { const XmlElement *stanza = NextStanza(); if (stanza == NULL) return STATE_BLOCKED; const XmlChild *child = stanza->FirstChild(); if (!child) return STATE_START;

const XmlElement *body = child->AsElement(); if (body != NULL) { std::cout << "received message " << body->BodyText().c_str() << " from " << stanza->Attr(QN_FROM).c_str() << std::endl; XmlElement *result = new XmlElement(QN_MESSAGE); result->AddAttr(QN_FROM, GetClient()->jid().Str()); result->AddAttr(QN_TO, stanza->Attr(QN_FROM)); result->AddAttr(QN_TYPE, STR_CHAT); // result->AddAttr(QN_ID, stanza->Attr(QN_ID)); result->AddElement(new XmlElement(QN_BODY)); result->AddText("test reply", 1); SendStanza(result); }

return STATE_START;

}

So the problem is somewhere here.

const XmlElement *body = child->AsElement(); if (body != NULL) {

Body is always NULL. I don't know how I should read out the content of the message.