I have documentation on my project site on codeplex, and i want to create a PHP code to embed it to my site. and this is the part of code i want to get from the page. If you could help me it would be great.
This is the code i want to extract from https://mxspli.codeplex.com/documentation :
<div id="WikiContent" class="WikiContent">
<div class="wikidoc">
<h1><img src="https://download-codeplex.sec.s-msft.com/Download?ProjectName=mxspli&DownloadId=1564842&Build=21031" alt="" width="101" height="23"> Documentation</h1>
<p>Welcome to MXSPLI Documentation</p>
<p>Here you can learn how to use MXSPLI, and how to make libraries for it.</p>
<ul>
<li><a href="https://mxspli.codeplex.com/wikipage?title=Tutorials">Tutorials</a> </li><li><a href="https://mxspli.codeplex.com/wikipage?title=Released%20Libraries">Released Libraries</a>
</li><li><a href="https://mxspli.codeplex.com/wikipage?title=Main%20Functions">Main Functions</a>
</li></ul>
</div>
<div></div>
</div>
You can use DOMDocument
in PHP.
<?php
$pageHtml = file_get_contents('https://mxspli.codeplex.com/documentation');
$document = new DOMDocument();
@$document->loadHtml($pageHtml);
/* Write out the HTML snippet */
echo $document->saveHTML($document->getElementById('WikiContent'));
Strpos will find the position of the string
$string = file_get_contents('https://mxspli.codeplex.com/documentation');
$pos = strpos($string,'<div id="WikiContent" class="WikiContent">');
$pos2 = strpos($string, "<div></div>", $pos);
$newstring = substr($string, $pos, ($pos2-$pos));
Echo $newstring;
Edit: I just noticed you wanted the html tags? If you don't want the tags check my first version of this answer.
EDIT2: sorry it didn't work when I tested it, but now it does.
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.