website named XML2 using WebMatrix This website is made of t

website named XML2 using WebMatrix. This website is made of the XML file books.xml and the HTML file dcfault.html. In the HTML file, write JavaScript code that dynamically changes the XML DOM created on the client side from books.xml as following. Delete the and elements from the second book. Add a clement to every book, with text \"Pearson\" and attribute \"academic\". The attribute can only have value \"yes\" or \"no\". A random number generator should be used to determine the attribute value of each element\'s attribute value. Print out nodeName and nodeValue properties of all first generation child nodes of first book element. Print out nodeName and nodeValue properties of all first generation child nodes of the new clement of the second book clement.

Solution

<bookstore>
<book>
    <title>Everyday </title>
    <author>john</author>
    <year>2006</year>
    <price>40.00</price>

<book publisher=\"pearson\"></book>
</book>
<book>
    <title>Harryr</title>
    <author>Rowling</author>
    <year>2009</year>  
    <price>30</price>
    <book publisher=\"pearson\"></book>
</book>
</bookstore>

if (isset($_POST[\'rowNumber\'])) {

    $rowNumber = $_POST[\'rowNumber\'];
    $file = $_POST[\'file\'];

    $dom = new DOMDocument();
    $dom->load(\"../XML/\".$file);    
    $xml = $dom->documentElement;
    //PROBLEM HERE
    $xml->childNodes->item(0)->parentNode->removeChild($xml->childNodes->item($rowNumber));

    $handle = fopen(\"../XML/\".$file, \'w\');
    fwrite($handle, $dom->saveXML());

}


$xml->childNodes->item(0)->parentNode->removeChild($xml->childNodes->item(2));
   

 website named XML2 using WebMatrix. This website is made of the XML file books.xml and the HTML file dcfault.html. In the HTML file, write JavaScript code that

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site