Slick and XML
by sanford
CSS
* { padding: 18px; white-space: pre; }
JavaScript
new Request({
url: '/echo/xml/',
data: {
xml: '<?xml version="1.0" encoding="UTF-8" ?><root><test id="test1"></test><test id="test2"><innertest id="itest1"></innertest></test></root>'
},
method: 'post',
onSuccess: function(respT,respX){
bod = $(document.body);
bod.appendText( 'searching for selector "#test1"... ' );
Array.each( Slick.search( respX, '#test1' ), function( itm, idx ) {
id = ( itm.get && itm.get('id') ) || itm.getAttributeNode('id').value;
bod.appendText( 'found element with id ' + id );
});
bod.appendText('\n');
bod.appendText( 'searching for selector "test > innertest"... ' );
Array.each( Slick.search( respX, 'test > innertest' ), function( itm, idx ) {
id = ( itm.get && itm.get('id') ) || itm.getAttributeNode('id').value;
bod.appendText( 'found element with id ' + id );
});
}
}).send();