E4X element manipulation
I'm trying to use E4X to do some HTML cleanup and manipulation, and am missing something basic I think.
Given:
<head>
<title>body</title>
</head>
<body id="body" lang="en-US">
<div>
<div class="Chapter">
<h2>
Summary
</h2>
<p>
asdf jaskdlf jksdlf jkdsal fjklaf
</p>
<p>
jkdlf; ajskdfl ;asjkfl sajdfk ;adjskfl;
</p>
</div>
</div>
</body>
</html>;
var myChapter = myXML.body.div.div.(attribute("class")=="Chapter");
var myParent = myChapter.parent();
I've figured out how to locate elements and attributes in the XML. But I can't seem to move the content in the XML. For example, I'd like to move the <div class="Chapter"> element and it's children in place of the parent <div> (effectively removing the redundant div) but can't figure it out. I've wrestled with insertChildBefore() and replace(), but can't seem to work it out.
Oh great minds...any suggestions?