Skip to content

Instantly share code, notes, and snippets.

@abhinavsingh
Created September 12, 2012 17:10
Show Gist options
  • Save abhinavsingh/3708233 to your computer and use it in GitHub Desktop.
Save abhinavsingh/3708233 to your computer and use it in GitHub Desktop.
JAXLXml chaining api methods example
$ ./jaxlctl shell
jaxl 1> $xml_obj = new JAXLXml('message', array('to'=>'[email protected]', 'from'=>'[email protected]'));
jaxl 2> $xml_obj->c('body')->attrs(array('xml:lang'=>'en'))->t('Hello World!')->up()
....... ->c('thread')->t('id-1234')->up()
....... ->c('nested-stuff')
....... ->c('nest')->t('nest1')->up()
....... ->c('nest')->t('nest2')->up()
....... ->c('nest')->t('nest3')->up()->up()
....... ->c('c')->attrs(array('hash'=>'84jsdmnskd'));
jaxl 3> echo $xml_obj->to_string();
'<message to="[email protected]" from="[email protected]"><body xml:lang="en">hello</body><thread>1234</thread><nested><nest>nest1</nest><nest>nest2</nest><nest>nest3</nest></nested><c hash="84jsdmnskd"></c></message>'
jaxl 4>
jaxl 4> quit
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment