The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

Parse XML using Rhino included E4X. Much easier than using SAX or DOM.

Clement Wong
Clement Wong EM mod
edited December 20, 2017 in DevShare #1
It’s very simple to parse XML in BIRT scripting using Rhino’s included extension, E4X ( With E4X, XML is a primitive and is easy to access. So there’s no need for Java SAX and DOM packages.

The attached example retrieves an RSS feed from ESPN’s Top Headlines using a Scripted Data Source. Here are a few highlights, and look at the fetch event and you’ll see XML elements are accessed via dot notation.



var inStream = new URL("").openStream();
var inStreamReader = new InputStreamReader(inStream);
var bufferedReader = new BufferedReader(inStreamReader);
var line;
var result = "";
while ((line = bufferedReader.readLine()) != null)
       result += line;

//logger = java.util.logging.Logger.getLogger("");
//logger.warning (result);

//Remove the first line <?xml version="1.0" ?>" to make it well formed XML
result = result.replace(/<\?[^>]*>/g,""); 

rss = new XML(result);
totalItems =;


if( currentrow >= totalItems ){
       return false;

row["title"] =[currentrow].title.toString();
row["description"] =[currentrow].description.toString();
row["link"] =[currentrow].link.toString();
row["pubDate"] =[currentrow].pubDate.toString();

currentrow += 1;
return true;

This example was tested in commercial BIRT iHub 3.1 and OS BIRT 4.4.2, and it should work in earlier versions of BIRT. E4X was removed from Rhino in 2014, but these versions of BIRT still include the version of Mozilla Rhino JavaScript which still has E4X.

Clement Wong
Principal Analytics Architect

OpenText Corporation |