문제

I'm having some trouble understanding how to use the Strophe Library for Dataforms. I'm quite new to this and from what I know, users are expected to understand how to use the library from the Source Code.

Below is the source code:

https://github.com/metajack/strophejs-plugins/blob/master/dataforms/src/strophe.x.js

In essence, I am sending a packet (xml packet which I am creating) to a plugin and am seeing an xml response in a format shown below:

<command xmlns="http://jabber.org/protocol/commands" sessionid="CQ0MBeI" status="completed">
  <note type="info">Operation finished successfully</note>
  <x xmlns="jabber:x:data" type="result">
    <reported>
    <item>
    <item>
    <item>
  </x>
</command>

I want to convert this into html (which would use toHTML) but I'm not sure how to do this.

Any advice or pointers in the right direction would be brilliant please, or if anyone knows of an example of it's use on the web.

Thank you for your time.

Kind Regards,

Gary Shergill

도움이 되었습니까?

해결책

Okay, took a while with trial and error, and as always I find the solution shortly after posting...

So, for anyone else having trouble with this you do it as follows:

  1. Your XML packet returned should have a variable name, lets say "discoResult".

  2. You convert this XML as below:

    var discoResultFromXml = Form.fromXML(discoResult);

  3. You convert this into a html form:

    var discoResultToHtml = discoResultFromXml.toHTML();

  4. Done! Now you need to display this form somewhere (this is where I'm stuck and will be posting a new topic, which I'll link in the comment here).

Hope this helps someone!

Kind Regards,

Gary Shergill

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top