XML DOMLesson 41Free preview
DOM Replace Nodes
This lesson is part of XML · All levels
Summary
Old nodes can be replaced with new nodes through the parent-owned replaceChild, which receives new nodes and old nodes as arguments. When only text content is needed, textContent is often more practical. The node is automatically replaced apart from the tree.
Key points
- ReplaceChild replaces old node with new node
- The call is made to the parent of the old node
- Old nodes automatically detach from the tree
- Replacing text content can be done simply with textContent
- Substitution is useful for gradual content updating
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.