Andrew Ballard wrote:
On Wed, Mar 11, 2009 at 11:52 AM, Michael A. Peters <mpeters@xxxxxxx> wrote:
If I'm manipulating a dom object, is there a way to change the tag name?
I know you manipulate just about everything else in a node - but is the
tagName really off limits?
from the documentation for DOMElement -
/* Properties */
readonly public bool $schemaTypeInfo ;
readonly public string $tagName ;
so if I really needed to change it, I'd have to create a virgin node with
the new name, identical attributes and children, and replace the existing
node with the new one?
Is there any other way to alter the tagName without doing all that?
If this is related to your earlier post about attributes, is XSLT not
an option? I hate to sound like a broken record, but PHP has support
for XSL transformations and it sounds like that is exactly what you
are trying to do.
Andrew
No.
XSLT is certainly one of the technologies I'm going to look into, but
right now I'm building a filter that (hopefully) will fully implement
the Mozilla developer Content Security Policy server side before the
document gets sent to the browser - by removing what would violate the
specified CSP before it is sent.
My primary interest in changing tag names is to ensure all tags are
lower case so I can then run the rest of the filter. They are all lower
case if you use loadHTML() but I don't want my class to assume it has a
properly created DOMDocument to start with, so I want to walk the DOM
and change bad tags/attribute names before I apply the CSP filtering.
That might be something where XSLT is better but I believe I need to
install some libraries and recompile php before I can use XSLT as it
appears my current build doesn't support it (according to phpinfo()) so
playing with XSLT is for another day.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php