[jdev] XML::Stream question.....

Nicholas Perez nick at jabberstudio.org
Sun Feb 22 13:30:40 CST 2004


Have you considered using POE::Component::Jabber? 
http://www.jabberstudio.org/projects/pcj/project/view.php I know you are 
looking for simple, and you should just be able to get the cvs and go 
from there. Several projects make use of PoCo::Jabber including punjab, 
sluice, and others. There are examples included. If you have any 
questions on using this code, let me know and I will help out the best I 
can.

Nick

troyer at xs4all.nl wrote:

>Hello everyone,
> 
>I am trying to build a rather simple perl script using the Ryan Eatmon's
>XML::Stream library.  Unfortunately, I am having a hard time getting the
>Send method to work.  The send method requires both a sid (stream id)
>and a
>XML string.  Below is the script that I am using.  Upto about line 18
>everything works fine.  On line 18, I would like to send out the xml:
><iq
>type="get"><query xmlns="jabber:iq:auth"/></iq>
> 
>I am assuming that the sid is the $stream hash?  Am I misunderstanding
>this?
> 
>Thanks,
> 
>Mark
>------------------------------------------------------------------------
>----
>-------
> 
>  use XML::Stream qw(Tree);
>  use Data::Dumper;
> 
>  my $already_sent = 0;
> 
>  my $stream = new XML::Stream(debug=>"stdout", debuglevel=>3);
> 
>  $stream->SetCallBacks(node=>\&noder);
> 
>  $stream->Connect(hostname => "compaq",
>                   port => 5222,
>                   namespace => "jabber:client",
>                   timeout => undef) || die $!;
> 
>  while(1) {
>            $stream->Process(1);
>            if (!$already_sent) {
>                        # Call to Send below does not work.  What am I
>doing
>wrong??
>                        $stream->Send($stream,'<iq type="get"><query
>xmlns="jabber:iq:auth"/></iq>');
>                        $already_sent = 1;
>            }
>  }
> 
> 
>  sub noder
>  {
>    my $sid = shift;
>    my $node = shift;
> 
>    # do something with $node
> 
>            print Dumper \$node
>  }
>
>_______________________________________________
>jdev mailing list
>jdev at jabber.org
>https://jabberstudio.org/mailman/listinfo/jdev
>
>  
>



More information about the JDev mailing list