Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Extract data from online API to text box/field of html page

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Extract data from online API to text box/field of html page
 Login/Join
 
Gold member
posted
Is there a way, maybe via javascript, to extract data from an online API to display in text boxes of an html page?

I found this api that has current weather:
http://api.openweathermap.org/...e=xml&units=imperial

looks like this:

<current>
<city id="5128581" name="New York">
<coord lon="-74.01" lat="40.71"/>
<country>US</country>
<sun rise="2014-10-30T11:24:46" set="2014-10-30T21:54:34"/>
</city>
<temperature value="56.07" min="51.8" max="59" unit="fahrenheit"/>
<humidity value="44" unit="%"/>
<pressure value="1015" unit="hPa"/>
<wind>
<speed value="9.94" name="Fresh Breeze"/>
<direction value="320" code="NW" name="Northwest"/>
</wind>
<clouds value="40" name="scattered clouds"/>
<visibility/>
<precipitation mode="no"/>
<weather number="802" value="scattered clouds" icon="03d"/>
<lastupdate value="2014-10-30T20:24:01"/>
</current>

can I extract the current temp : 56.07
and abbreviated conditions : Fresh Breeze and scattered clouds

and display on an html page in texboxes? Like parms?

I know this is advanced, so please be gentle.

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 768
OS/400
HTML, also quite a few active reports and excel.
 
Posts: 59 | Registered: June 18, 2009Report This Post
Expert
posted Hide Post
Please please please put the code you posted between code tags - we (you and us) cannot see the HTML.

[code]
your code here
[/code]


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
<current>
<city id="6941775" name="Kings County">
<coord lon="-74.01" lat="40.71"/>
<country>US</country>
<sun rise="2014-10-31T11:25:56" set="2014-10-31T21:53:20"/>
</city>
<temperature value="38.32" min="28.4" max="46.4" unit="fahrenheit"/>
<humidity value="70" unit="%"/>
<pressure value="1017" unit="hPa"/>
<wind><speed value="6.7" name="Moderate breeze"/>
<direction value="20" code="NNE" name="North-northeast"/>
</wind>
<clouds value="75" name="broken clouds"/>
<visibility/>
<precipitation mode="no"/>
<weather number="803" value="broken clouds" icon="04d"/>
<lastupdate value="2014-10-31T11:53:01"/>
</current>


WebFOCUS 768
OS/400
HTML, also quite a few active reports and excel.
 
Posts: 59 | Registered: June 18, 2009Report This Post
Virtuoso
posted Hide Post
Javascript is indeed an option, I suggest using JQuery to call that API and put the contents in a suitable element (a DIV perhaps).

I think you could even include that XML section into your page verbatim, provided that you supply style information for the tags used in it.
For that approach it is a bit unfortunate that all values are put into attributes instead of between tags though, that makes it difficult to style meaningfully.

Another option is to use an XSLT template to convert the XML into HTML.

I wonder though: if they provide an API, doesn't that include functions (Javascript) to transform that XML data into a HTML fragment that you could embed in your page?


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
You can use the WF Rest adaptor to read that URL directly and produce a report.

If you use JQuery, change it to json output to make it easier to work with.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Master
posted Hide Post
I was playing around with calling the Weather Channel web widget a while back.

Here is an example running against one of the IB sample files:

-*
-* Create Emergency Contact Report.
-*
DEFINE FILE PERSINFO
 WEATHER/A1024 =
    '<script type="text/javascript" src="'
 |  'http://voap.weather.com/weather/oap/'
 |  POSTALCODE
 | '?template=GENXH'
 |  '&' | 'par=3000000007'
 |  '&' | 'unit=0'
 |  '&' | 'key=twciweatherwidget'
 |  '"> </script>';
END
-*
TABLE FILE PERSINFO
"Emergency Contact Listing"
PRINT EMERGCONTACT AS 'Emergency Contact'
      CITY         AS 'City'
      STATE        AS 'State'
      POSTALCODE   AS 'Zip Code'
      WEATHER      AS 'Current Weather'
BY    EMERGCONTACT NOPRINT
IF COUNTRY EQ USA
IF RECORDLIMIT EQ 10
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET PAGE OFF
ON TABLE SET STYLE *
 INCLUDE = ENInformationBuilders_Light1, $
 TYPE=HEADING,COLOR='WHITE',BACKCOLOR=RGB(#4F81BD),$
 TYPE=TITLE, JUSTIFY=CENTER,$
ENDSTYLE
ON TABLE SUBFOOT
"Fex: &FOCFEXNAME"
END
-RUN  

35 in Jacksonville tonight!?!?!?!?!
 
Posts: 822 | Registered: April 23, 2003Report This Post
Member
posted Hide Post
That is really slick David.


WebFOCUS 8.0.05
Windows- Excel, PDF
 
Posts: 21 | Location: Crystal City, VA & Kalamazoo, MI | Registered: October 11, 2010Report This Post
Platinum Member
posted Hide Post
David - very, very cool!


webFOCUS 8207.15
WindowsServer 2019
 
Posts: 120 | Location: Minnesota | Registered: August 26, 2013Report This Post
Platinum Member
posted Hide Post
 DANEWS/A1024 =
 '<script type="text/javascript" src="'
 |  'http://nmp.newsgator.com/NGBuzz/buzz.ashx'
 |  '?buzzId=16934'
 |  '&' | 'apiToken=BA7717C6DDBD407AA7FC6327F1861493'
 |  '&' | 'trkp='
 |  '&' | 'trkm='
 |  '"> </script>';


One extra DEFINE to get news. Granted - this one isn't based on Zipcode like David's weather. I couldn't find a newsfeed based on zip - but I'd think something like that us be out there.


webFOCUS 8207.15
WindowsServer 2019
 
Posts: 120 | Location: Minnesota | Registered: August 26, 2013Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Extract data from online API to text box/field of html page

Copyright © 1996-2020 Information Builders