$str = \'some text tag contents more text \';
My questions are:
How to retrieve content tag contents
which is between
You do not want to use regular expressions for this. A much better solution would be to load your contents into a DOMDocument and work on it using the DOM tree and standard DOM methods:
$document = new DOMDocument();
$document->loadXML(' ');
$document->documentElement->appendChild(
$document->createFragment($myTextWithTags));
$MY_TAGs = $document->getElementsByTagName('MY_TAG');
foreach($MY_TAGs as $MY_TAG)
{
$xmlContent = $document->saveXML($MY_TAG);
/* work on $xmlContent here */
/* as a further example: */
$ems = $MY_TAG->getElementsByTagName('em');
foreach($ems as $em)
{
$emphazisedText = $em->nodeValue;
/* do your operations here */
}
}