Hello,Alex
I write a method the get the XML content
private void XmppCon_OnWriteXml(object sender, string xml)
{
System.Console.WriteLine("------START SEND-------------------");
System.Console.WriteLine("send:" + xml);
System.Console.WriteLine("-------END SEND------------------");
}
And here's the output
-------START RECEIVE------------------
receive:<iq xmlns="jabber:client" to="abc@roger/agsXMPP" type="result" id="agsXMPP_3"><query xmlns="botwave:token"><IESCommandJavaBean>
<commandBaseBean>
<commandName>ies.getquestionlist</commandName>
</commandBaseBean>
<page>
<pageNum>1</pageNum>
<pageSize>10</pageSize>
<recordCount>48</recordCount>
</page>
<question>
<content>??????????</content>
<qid>1</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:45:18</time>
<title>?????</title>
</question>
<question>
<content>?????????</content>
<qid>2</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:50:41</time>
<title>??????</title>
</question>
<question>
<content>????????</content>
<qid>3</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:51:54</time>
<title>?????</title>
</question>
<question>
<content>????????????</content>
<qid>4</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:53:07</time>
<title>???????</title>
</question>
<question>
<content>???????????????????...</content>
<qid>5</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:54:42</time>
<title>???????????</title>
</question>
<question>
<content>?????????????3?????...</content>
<qid>6</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:55:26</time>
<title>?????“3”</title>
</question>
<question>
<content>????????2??“2”?“2”????...</content>
<qid>7</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:55:55</time>
<title>?????“2”</title>
</question>
<question>
<content>“1”?????????????????...</content>
<qid>8</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:56:24</time>
<title>?????“1”</title>
</question>
<question>
<content>?????????????????????...</content>
<qid>9</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:56:52</time>
<title>????-----???????</title>
</question>
<question>
<content>???????????????????...</content>
<qid>10</qid>
<questioner>abc</questioner>
<status>???</status>
<time>2007-12-05 17:57:14</time>
<title>?????????</title>
</question>
</IESCommandJavaBean></query></iq>
--------END RECEIVE-----------------
I copy this content into my local file content.xml
and try the test code,the ElementFactory.AddElementType() was copy from my real program
static void Main()
{
ElementFactory.AddElementType(IESTagName.IESQuery, IESTagName.IESNameSpace, typeof(IESQuery));
ElementFactory.AddElementType(IESTagName.IESCommandBean, IESTagName.IESNameSpace, typeof(IESCommandBean));
ElementFactory.AddElementType(IESTagName.CommandBaseBean, IESTagName.IESNameSpace, typeof(IESCommandBaseBean));
ElementFactory.AddElementType(IESTagName.Question, IESTagName.IESNameSpace, typeof(Question));
ElementFactory.AddElementType(IESTagName.Answer, IESTagName.IESNameSpace, typeof(Answer));
ElementFactory.AddElementType(IESTagName.PersonalSetting, IESTagName.IESNameSpace, typeof(PersonalSetting));
ElementFactory.AddElementType(IESTagName.PointRecord, IESTagName.IESNameSpace, typeof(PointRecord));
ElementFactory.AddElementType(IESTagName.Message, IESTagName.IESNameSpace, typeof(ClientUI.ies.commandbean.Message));
ElementFactory.AddElementType(IESTagName.Page, IESTagName.IESNameSpace, typeof(Page));
Document doc = new Document();
doc.LoadFile(@"c:\content.xml");
//Element iq = doc.RootElement.SelectSingleElement("iq",true);
IQ iq = doc.RootElement as IQ;
IESQuery query = iq.SelectSingleElement(typeof(IESQuery)) as IESQuery;
IESCommandBean commandbean = iq.SelectSingleElement(typeof(IESCommandBean), true) as IESCommandBean;
Question question = iq.SelectSingleElement(typeof(Question), true) as Question;
IESCommandBaseBean basebean = commandbean.BaseBean;
Page page = iq.SelectSingleElement(typeof(Page),true) as Page;
ElementList el = commandbean.SelectElements(typeof(Question));
ArrayList qlist = new ArrayList();
foreach (Question q in el) {qlist.Add(q);}
}
the code work really fine, the query,commandbean,question,basebean,page even the qlist get their own value,so I think there should no problem in ElementFactory~
But in my real program
void XmppCon_OnIq(object sender, agsXMPP.protocol.client.IQ iq)
{
if (iq.Query.GetType() == typeof(IESQuery))
{
IESQuery query = iq.SelectSingleElement(typeof(IESQuery)) as IESQuery;
IESCommandBean commandbean = iq.SelectSingleElement(typeof(IESCommandBean),true) as IESCommandBean;
Question question = iq.SelectSingleElement(typeof(Question),true) as Question;
IESCommandBaseBean basebean = commandbean.BaseBean;
switch (basebean.CommandName)
.
.
.
They are almost the same as the test code,but only the [IESQuery query] get its value,the commandbean,question,basebean are null, I have no idea why this happen~