I noticed a weird behaviour when trying to display some text included within the less than and greater than symbols extracted from an XML file.
Try the following example:
$xml = '<doc>
<one><<Hello>> "Hello" inside less than and greater than symbols will not be printed</one>
<two><< Hello>> "Hello" is printed because there is a space after "<" </two>
</doc>';
$simple = simplexml_load_string($xml);
echo "<pre>";
print_r($simple);
echo "</pre>";
echo "This works fine: <<Hello>>";
As you may notice, if there's no space after the less than symbol the text between is not displayed and only one less than and one greater than symbol is shown.
The problem is that the XML file I'm working on happens to have some text included between the less than and greater than symbols without any space after the less than symbol. By the way, if you look at the source code (Ctrl-U) in your browser the text is displayed correctly:
<pre>SimpleXMLElement Object
(
[one] => <<Hello>> "Hello" inside less than and greater than symbols will not be printed
[two] => << Hello>> "Hello" is printed because there is a space after "<"
)
</pre>
This works fine: <<Hello>>
It is printed, but not displayed in browser because it interpret it as an html tag. You need to escape html characters with htmlspecialchars for all nodes you print.