I know that this topic was posted everywhere but their question is not that I want to. Without touching the original code in the page, I want to add some HTML code.
Suppose my header was provided by a function called render_header ():
function render_body () {return "from & Lt; div class = 'container' & gt; div class = 'one' & gt; & lt; / div & gt; & lt; div class = 'b' & gt; b & lt; ; / Div> & lt; / div & gt; & lt; / body & gt; "; }
From now on, I want to use the HTML code without editing PHP render_body () . I would like a function that insert some divisions into container David .
render_ body (); & Lt ;? Enter Php * // '& lt; Div class = "c" * inside devell container? & Gt; As an alternative to using XPath - it should load from output to .
object on an XML object and assign the object to your HTML Ask so that you can work smoothly, where you want to incorporate new HTML.
This will hardly work if you are still using HTML using XML.
// The document reads $ xml = new domdom (); $ Xml- & gt; LoadHTML (render_body ()); // Create an XPath query object $ xpath = new DOMXpath ($ xml); // Create the HTML node that you would get $ xml- & gt; Want to add // using CreateElement () ... // Find that node in which you can add new content $ xmlDivClassA = $ xpath- & gt; Query ('/ / body / div [@ class = "one"]') - & gt; Item (0); $ XmlDivClassA- & gt; Append Cold (/ * HTML node you have created before /); // output echo $ xml- & gt; Save HTML ();
For a while, I had to mention the documentation ... too much JQuery has recently ruined my ability to manipulate the DOM without seeing things:
Comments
Post a Comment