/**
* Replaces node contents.
*
* Needed as a workaround for bug/feature of set_content.
* This version puts the content
* as the first child of the new node.
* If you need it somewhere else, simply
* move $newnode->set_content() where
* you want it.
* Credit: http://www.php.net/manual/en/function.domnode-set-content.php
*/
function xml_replace_nodeContent( &$node, &$new_content )
{
$dom =& $node->owner_document();
$newnode =& $dom->create_element( $node->tagname );
$newnode->set_content( $new_content );
$atts =& $node->attributes();
foreach ( $atts as $att )
{
$newnode->set_attribute( $att->name, $att->value );
}
$kids =& $node->child_nodes();
foreach ( $kids as $kid )
{
if ( $kid->node_type() != XML_TEXT_NODE )
{
$newnode->append_child( $kid );
}
}
return $newnode;
}
PHP and javascript snippets you can copy and paste.
Showing posts with label php xml xml_replace_nodeContent. Show all posts
Showing posts with label php xml xml_replace_nodeContent. Show all posts
Wednesday, April 4, 2007
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2007
(71)
-
▼
June
(20)
- js_move_elementToYPos(element, yPoint)
- js_move_elementToXPos(element, xPoint)
- js_move_elementHorizontal(element, shiftHoriz)
- js_move_elementVertical(element, shiftVertical)
- js_get_rand(max)
- js_get_isEven(n)
- js_is_odd(n)
- js_get_screenCenterY()
- js_get_screenCenterX()
- js_get_elementTop()
- js_get_elementLeft()
- js_get_elementHeight()
- js_get_elementWidth
- js_get_pageWidth()
- js_get_pageHeight()
- js_get_scrollTop()
- js_get_scrollLeft()
- js_get_browserInnerHeight
- js_get_browserInnerWidth
- js_get_pageInnerWidth
-
▼
June
(20)