<div class="fadeIn portfolio-item mix [[+Date:strtotime:date=`%Y`]]"> <div class="service-two newsstuff [[+idx]] "> <a href="[[+NewsRelease.ReleaseID]]"> <i class="icon wow fadeInLeft news"></i> <h3>[[+Title:ellipsis=`30`]]</h3> <span>NEWS ARTICLE ADDED // [[+Date:strtotime:date=`%m-%d-%Y`]]</span> <p>[[+Title:ellipsis=`75`]]</p> </a> </div><!-- end service --> </div><!-- end col-->
[[!parsex? &source=`http://xml.corporate-ir.net/irxmlclient.asp?compid=251258&reqtype=newsreleases_2` &limit=`5` &tpl=`newsarticles` &element=`NewsRelease` &wrapper=`wrapX`]]
<IRXML CorpMasterID="251258"> <NewsReleases PubDate="20150512" PubTime="21:05:53"> <NewsRelease ReleaseID="2047271" DLU="20150512 21:00:31" ArchiveStatus="Current" RNSSource="" ContainerId="" Type="2"> <Title>GasLog Ltd. Announces Election of Directors at 2015 Annual General Meeting of Shareholders</Title> <ExternalURL/> <Date Date="20150512" Time="17:00:31" TimeZone="ET"> 5/12/2015 5:00:31 PM </Date> <DisplayDateStart Date="20150512" Time="17:00:31">May 12 2015 05:00</DisplayDateStart> <DisplayDateEnd Date="20350512" Time="21:00:31">May 12 2035 09:00</DisplayDateEnd> <ContentNetworkingLinks/> <Categories> <Category>NA</Category> </Categories> </NewsRelease> <NewsRelease ReleaseID="2044578" DLU="20150506 11:23:15" ArchiveStatus="Current" RNSSource="" ContainerId="" Type="2"> <Title>GasLog Ltd. Reports Financial Results for the Quarter Ended March 31, 2015</Title> <ExternalURL/> <Date Date="20150506" Time="07:23:15" TimeZone="ET">5/6/2015 7:23:15 AM</Date> <DisplayDateStart Date="20150506" Time="07:23:15">May 06 2015 07:23</DisplayDateStart> <DisplayDateEnd Date="20350506" Time="11:23:15">May 06 2035 11:23</DisplayDateEnd> <ContentNetworkingLinks/> <Categories> <Category>NA</Category> </Categories> </NewsRelease> <NewsRelease ReleaseID="2038092" DLU="20150421 11:00:39" ArchiveStatus="Current" RNSSource="" ContainerId="" Type="2"> <Title>GasLog and GasLog Partners Announce the Time Charter of up to 9 Newbuildings to BG Group plc</Title> <ExternalURL/> <Date Date="20150421" Time="07:00:39" TimeZone="ET">4/21/2015 7:00:39 AM</Date> <DisplayDateStart Date="20150421" Time="07:00:39">Apr 21 2015 07:00</DisplayDateStart> <DisplayDateEnd Date="20350421" Time="11:00:39">Apr 21 2035 11:00</DisplayDateEnd> <ContentNetworkingLinks/> <Categories> <Category>NA</Category> </Categories> </NewsRelease> <NewsRelease ReleaseID="2037664" DLU="20150420 12:30:26" ArchiveStatus="Current" RNSSource="" ContainerId="" Type="2"> <Title>GasLog Ltd. Announces Date for 2015 First Quarter Results</Title> <ExternalURL/> <Date Date="20150420" Time="08:30:26" TimeZone="ET">4/20/2015 8:30:26 AM</Date> <DisplayDateStart Date="20150420" Time="08:30:26">Apr 20 2015 08:30</DisplayDateStart> <DisplayDateEnd Date="20350420" Time="12:30:26">Apr 20 2035 12:30</DisplayDateEnd> <ContentNetworkingLinks/> <Categories> <Category>NA</Category> </Categories> </NewsRelease> </NewsRelease> </NewsReleases> </IRXML>
<?php # Snippet to read and parse XML input # USAGE: [[!parsex? &source=`feed.rss` &tpl=`xmlTpl`]] # author: [email protected] //$modx->setDebug(true); $source = $modx->getOption('source', $scriptProperties, 'http://modx.com/feeds/latest.rss'); $element = $modx->getOption('element', $scriptProperties, 'item'); $tpl = $modx->getOption('tpl', $scriptProperties, 'xmlTpl'); $wrapper = $modx->getOption('wrapper', $scriptProperties, 'wrapX'); $limit = $modx->getOption('limit', $scriptProperties, 0); $debugmode = $modx->getOption('debugmode', $scriptProperties, false); if (empty($source)) { $modx->log(modX::LOG_LEVEL_ERROR,'[parseX] Empty source adress passed, aborting.'); return 'No source definded.'; } else { if ($xml = simplexml_load_string(file_get_contents($source))) { #$modx->log(modX::LOG_LEVEL_ERROR,'[parseX] can read file: '.$source); #$modx->log(modX::LOG_LEVEL_ERROR,'[parseX] element value '.$element); $nodes = $xml->xpath("//$element"); $nodecount = 0; foreach ($nodes as $node) { if (($debugmode==true) && ($nodecount==0)) { var_dump($node); } $values = array(); $attrib = $node->attributes(); foreach ($attrib as $attrkey => $attrval) { $values['.'.$attrkey] = (string)$attrval; } foreach($node as $key => $value) { if ($key == 'pubDate') { $value = strftime("%d.%m.%Y %H:%M:%S", strtotime($value)); } $values[$key] = (string)$value; foreach ($node->$key->attributes() as $attrkey => $attrval) { $values[$key.'.'.$attrkey] = (string)$attrval; } } if ($debugmode==true && $nodecount==0) { var_dump($values); } $output .= $modx->getChunk($tpl, $values); $nodecount++; if (($nodecount >= $limit) && ($limit !=0)) break; } } else { $modx->log(modX::LOG_LEVEL_ERROR,'[parseX] can NOT read file: '.$source); } $result = array("result" => $output); return $modx->getChunk($wrapper, $result); }
<?php # Snippet to read and parse XML input # USAGE: [[!parsex? &source=`feed.rss` &tpl=`xmlTpl`]] # author: [email protected] //$modx->setDebug(true); $source = $modx->getOption('source', $scriptProperties, 'http://modx.com/feeds/latest.rss'); $element = $modx->getOption('element', $scriptProperties, 'item'); $tpl = $modx->getOption('tpl', $scriptProperties, 'xmlTpl'); $wrapper = $modx->getOption('wrapper', $scriptProperties, 'wrapX'); $limit = $modx->getOption('setlimit', $scriptProperties, 0); $debugmode = $modx->getOption('debugmode', $scriptProperties, false); if (empty($source)) { $modx->log(modX::LOG_LEVEL_ERROR,'[parseX] Empty source adress passed, aborting.'); return 'No source definded.'; } else { if ($xml = simplexml_load_string(file_get_contents($source))) { #$modx->log(modX::LOG_LEVEL_ERROR,'[parseX] can read file: '.$source); #$modx->log(modX::LOG_LEVEL_ERROR,'[parseX] element value '.$element); $nodes = $xml->xpath("//$element"); $nodecount = 0; foreach ($nodes as $node) { $nodecount++; $values = array(); $releaseId = null; foreach ($node->attributes() as $attrKey => $attrVal) { if ($attrKey == 'ReleaseID') { $releaseId = (string)$attrVal; } } foreach ($node as $key => $value) { if ($key == 'pubDate') { $value = strftime("%d.%m.%Y %H:%M:%S", strtotime($value)); } $values[$key] = (string)$value; $values['ReleaseID'] = $releaseId; foreach ($node->$key->attributes() as $attrkey => $attrval) { $values[$key.'.'.$attrkey] = (string)$attrval; } } if ($debugmode==true) { var_dump($values); } $output .= $modx->getChunk($tpl, $values); if ($nodecount >= $limit) break; } } else { $modx->log(modX::LOG_LEVEL_ERROR,'[parseX] can NOT read file: '.$source); } $result = array("result" => $output); return $modx->getChunk($wrapper, $result); }