Jump to content

BIRT Developer Center Download


Submitter

File Information

  • Submitted: Jul 27 2015 09:33 AM
  • Last Updated: Jul 29 2015 03:03 PM
  • File Size: 16.11KB
  • Views: 8235
  • Downloads: 40
  • Approved by: Clement Wong
  • Approved on: 29 July 2015 - 03:04 PM
  • Summary: Parse XML using Rhino included E4X. Much easier than using SAX or DOM.
  • Content Type: Designs & Code
  • BIRT Version: iHub3, Actuate 11, Actuate 10, 4.4, 4.3, 4.2, 3.7

Download Parsing XML in BIRT with E4X

- - - - -
xml sax dom e4x rss



Screenshots
It’s very simple to parse XML in BIRT scripting using Rhino’s included extension, E4X (https://developer.mo...ng_XML_with_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.

beforeOpen


rss = new XML(result);
totalItems = rss.channel.item.length();


fetch

if( currentrow >= totalItems ){
return false;
}

row["title"] = rss.channel.item[currentrow].title.toString();
row["description"] = rss.channel.item[currentrow].description.toString();
row["link"] = rss.channel.item[currentrow].link.toString();
row["pubDate"] = rss.channel.item[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.







  • 997 Total Files
  • 8 Total Categories
  • 153 Total Authors
  • 31706 Total Downloads
  • Joyplot in iHub Latest File
  • Clement Wong Latest Submitter

0 user(s) are online (in the past 1 minutes)

0 members, 0 guests, 0 anonymous users