List of usage examples for com.liferay.portal.kernel.xml Attribute getData
public Object getData();
From source file:com.liferay.weather.util.WeatherWebCacheItem.java
License:Open Source License
protected Weather doConvert() throws Exception { String xml = HttpUtil.URLtoString("http://api.openweathermap.org/data/2.5/weather?q=" + HttpUtil.encodeURL(_zip) + "&units=imperial&mode=xml"); Document document = SAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); Element cityElement = rootElement.element("city"); Attribute cityIdAttribute = cityElement.attribute("id"); String cityId = cityIdAttribute.getText(); Element temperatureElement = rootElement.element("temperature"); Attribute temperatureAttribute = temperatureElement.attribute("value"); float temperature = GetterUtil.getFloat(temperatureAttribute.getData()); Element weatherElement = rootElement.element("weather"); Attribute iconAttribute = weatherElement.attribute("icon"); String iconURL = "http://openweathermap.org/img/w/" + iconAttribute.getText() + ".png"; return new Weather(_zip, cityId, iconURL, temperature); }