How to remove CDATA tag in php?

You can definitely remove the CDATA tag from input xml by using the str_replace function in PHP to remove the desired content from your xml.

1. Code:

<?php 
    function removeCDataTag($string){
        $string = str_replace('<![CDATA[', '', $string);
        $string = str_replace(']]>','',$string);
        return $string;
    }
    function escapeSpecialChars($str){
        return htmlspecialchars($str, 1, "utf-8");
    }
    $str = '<?xml version="1.0" encoding="UTF-8"?>
<Tutorials>
    <Post>
        <Code>
            <![CDATA[ 
            <?xml version="1.0" encoding="UTF-8"?>
            <Persons>
                <Person>
                   Soltuts Support 
                </Person>
            </Persons>
            ]]>
        </Code>
    </Post>
</Tutorials>';
echo escapeSpecialChars(removeCDataTag($str));
?> 

2. Example:

Input:

<?xml version="1.0" encoding="UTF-8"?>
<Tutorials>
    <Post>
        <Code>
            <![CDATA[ 
            <?xml version="1.0" encoding="UTF-8"?>
            <Persons>
                <Person>
                   Soltuts Support 
                </Person>
            </Persons>
            ]]>
        </Code>
    </Post>
</Tutorials>

Output:

<?xml version="1.0" encoding="UTF-8"?>
<Tutorials>
	<Post>
		<Code> <?xml version="1.0" encoding="UTF-8"?>
			<Persons>
				<Person> Soltuts Support </Person>
			</Persons>
		</Code>
	</Post>
</Tutorials>