# Introduction

To write a programs using XMPP technology you must understand the basic principles of it. Xmpppy uses it's own implementation of XML handling procedures - so you should get used to it. Though it is simple enough I hope.

<dn>Node class</dn>

<dn>prototype</dn>
Node.__init__(name='', attrs={}, payload=[], parent=None, node=None)
<dn>Note that 'name' argument really consists of namespace and node name, space separated. Example:</dn>
node=Node('jabber:client message', attrs={'to':'target@jid.com'},payload=[Node('body',payload=['Hello target!'])])
or
node=Node('jabber:client message')
node['to']='target@jid.com'
node.NT.body='Hello target!'

NT stands for 'New Tag' and explicitly adds new child to the current node. Also the T can be used. That means "find Tag" but if tag exists it acts just like NT otherwise.
<dn>Protocol class</dn>
Uses similar syntax. We will use 'node' attribute now:

<dn>prototype</dn>
Protocol.__init__(name=None, to=None, typ=None, frm=None, attrs={}, payload=[], timestamp=None, xmlns='jabber:client', node=None)
<dn>example</dn>
p=Protocol(node=node)
or
proto=Protocol('message',to='target@jid.com',payload=[Node('body',payload=['Hello target!'])])
or
proto=Protocol('message',to='target@jid.com')
proto.NT.body='Hello target!'

<dn>Message class</dn>
Similar syntax:

<dn>prototype</dn>
Message.__init__(to=None, body=None, typ=None, subject=None, attrs={}, frm=None, payload=[], timestamp=None, xmlns='jabber:client', node=None)
<dn>example</dn>
m=Message(node=proto)
or
m=Message('target@jid.com','Hello target!')

<dn>Iq class</dn>
Similar syntax:

<dn>prototype</dn>
Iq.__init__(typ=None, queryNS=None, attrs={}, to=None, frm=None, payload=[], xmlns='jabber:client', node=None)
<dn>example</dn>
iq=Iq('set',NS_AUTH,payload=[Node('username',payload=['user']),Node('password',payload=['secret'])])
or
iq=Iq('set',NS_AUTH)
iq.T.query.NT.username='user'
iq.T.query.NT.password='secret'
or
iq=Iq('set',NS_AUTH)
iq.T.query.T.username='user'
iq.T.query.T.password='secret'
As I already noted - 'T' acts just like 'NT' if tag doesn't exists.

<dn>Presence class</dn>
Similar syntax:

<dn>prototype</dn>
Presence.__init__(to=None, typ=None, priority=None, show=None, status=None, attrs={}, frm=None, timestamp=None, payload=[], xmlns='jabber:client', node=None)
<dn>example</dn>
pres=Presence(priority=5, show='xa',status="I'm away from my computer")
or
pres=Presence()
pres.setPriority(5) pres.setShow('xa') pres.setStatus("I'm away from my computer") pres.setTimestamp() or
pres=Presence()
pres.T.priority=5 pres.T.show='xa' pres.T.status="I'm away from my computer" pres.setTimestamp()