Re: [PHP] PHP5, XPath and count()

[email protected] (Victor Boivie) Sat, 24 Jul 2004 21:26:58 +0200
Newsgroups php.xml.dev
Message-ID <[email protected]>
I posted this in php.general, but then I found this newsgroup. Maybe 
it's more suitable here (?)

    $dom = new DOMDocument();

    $root = $dom->createElement("test");
    $dom->appendChild($root);

    $node = $dom->createElement("foo", "which entities <i>does</i> it
  escape & which doesn't it?");
    $root->appendChild($node);

    echo $dom->saveXML();

  The result will be:

<?xml version="1.0"?>
  <test><foo>which entities &lt;i&gt;does&lt;/i&gt; it escape </foo></test>

  It stops at the &, which I think is strange. It escapes the < to &lt;
  and > to &gt;, but not & to &amp;. It would be better if it escaped none
  or all entites that "can do harm".

  Or what do you think?
  regards,
  Victor