Skip to content

Instantly share code, notes, and snippets.

@abhinavsingh
Created September 12, 2012 17:00
Show Gist options
  • Save abhinavsingh/3708124 to your computer and use it in GitHub Desktop.
Save abhinavsingh/3708124 to your computer and use it in GitHub Desktop.
JAXLXml example for top() and up() api
$ ./jaxlctl shell
jaxl 1> $xml_obj = new JAXLXml('message', 'jabber:client', array('to'=>'friend@domain.tld'));
jaxl 2> echo $xml_obj->to_string();
<message xmlns="jabber:client" to="friend@domain.tld"></message>
jaxl 3>
jaxl 3> // after this operation rover will point to `body` child node
jaxl 3> $xml_obj->c('body');
jaxl 4> echo $xml_obj->to_string();
<message xmlns="jabber:client" to="friend@domain.tld"><body></body></message>
jaxl 5>
jaxl 5> // this method will perform on `body` child node
jaxl 5> $xml_obj->t('Hello World!');
jaxl 6> echo $xml_obj->to_string();
<message xmlns="jabber:client" to="friend@domain.tld"><body>Hello World!</body></message>
jaxl 7>
jaxl 7> // move rover one step up
jaxl 7> $xml_obj->up();
jaxl 8>
jaxl 8> // if up() isn't performed above, `thread` child node would go as child of `body` node
jaxl 8> $xml_obj->c('thread');
jaxl 9> $xml_obj->t('some thread id or name');
jaxl 10> echo $xml_obj->to_string();
<message xmlns="jabber:client" to="friend@domain.tld"><body>Hello World!</body><thread>some thread id or name</thread></message>
jaxl 11>
jaxl 11> quit
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment