Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Last active Jul 15, 2016
Embed
What would you like to do?
Javascript file created to parse the XML Response Body
/**
* [1] Will be fired when the Apex
* Method completes execution.
*
* [2] Will also hold the data returned
* by the Apex Method after it
* completes execution.
*/
var searchTerm;
var newsFetchCompleted = function( res ) {
var parser = new DOMParser();
var xmlDoc = parser.parseFromString( res, "text/xml" );
var descriptions = xmlDoc.getElementsByTagName( "description" );
for( var i = 0 ; i <= descriptions.length - 1 ; i++ ) {
if( descriptions[i].textContent !== "Google News" ) {
$( "#news" ).append( descriptions[i].textContent );
$( "a" ).attr( "target" , "_blank" );
}
}
$( "#loader" ).hide();
};
function getNews( searchTerm ) {
NewsWidgetController.newsDisplayer( searchTerm,
newsFetchCompleted,
{
escape: false
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment