Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Last active July 15, 2016 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrutis22/a8bd5817390eac46ef64d0652fafffa2 to your computer and use it in GitHub Desktop.
Save shrutis22/a8bd5817390eac46ef64d0652fafffa2 to your computer and use it in GitHub Desktop.
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