Created
May 11, 2013 12:58
-
-
Save dipakcg/5559899 to your computer and use it in GitHub Desktop.
Display XML file contents in webpage using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$strContent = file_get_contents('YOUR-XML-FILE-PATH.xml'); // eg. http://www.SomeDomain.com/FileName.xml | |
$arrContent = new SimpleXmlElement($strContent, LIBXML_NOCDATA); | |
?> | |
<p> </p> | |
<div style="margin-left:25px; margin-right: 7px;"> | |
<h2>TITLE GOES HERE</h2> | |
<div> | |
<?php | |
$intI = 0; | |
foreach($arrContent->item as $key => $objContent) | |
{ | |
?> | |
<i> | |
<p style="margin-top:25px;"><?php | |
$strContent = $objContent->description; | |
if(strlen($strContent) > 220) | |
{ | |
echo substr($strContent,0,220).'...'; | |
} | |
else | |
{ | |
echo $strContent; | |
} | |
?> | |
</p> | |
</i> | |
<?php | |
$intI++; | |
if($intI == 3) | |
{ | |
break; | |
} | |
} | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment