"http://www.brianjaystanley.com/LIS/apps/rubiayat.xml", "tyger"=>"http://www.brianjaystanley.com/LIS/apps/tyger.xml", "leda"=>"http://www.brianjaystanley.com/LIS/apps/leda.xml", "sorrow"=>"http://www.brianjaystanley.com/LIS/apps/sorrow.xml"); //retrieve the appropriate filepath from the dictionary. $file = $poemdict[$poem]; //This function, which only executes if highlighting is on, gets the lines of the stanza making //the call and returns them as an array, for comparison with the stanzas being retrieved. function getLines($file,$version,$ID) { $lines = array(); //initialize array for storing lines $reader = new XMLReader(); //initialize reader $reader->open($file); //open file //move forward through the document, looking for the correct docEdition element node. while ($reader->read()) { if ($reader->nodeType == XMLReader::ELEMENT && $reader->localName == "docEdition") { $reader->read(); if ($reader->value == $version) { //start moving forward again; look for the lg element node with the correct //n attribute value. while ($reader->read()) { if ($reader->nodeType == XMLReader::ELEMENT && $reader->localName == "lg") { if ($reader->getAttribute("n") == $ID) { //then add the lines to an array. while ($reader->read()) { if ($reader->nodeType == XMLReader::ELEMENT && $reader->localName == "l") { $reader->read(); $lines[] = $reader->value; } //break loop at lg end tag. elseif ($reader->nodeType == XMLReader::END_ELEMENT && $reader->localName == "lg") { break; } } } } //break loop at text end tag (signaling end of version) elseif ($reader->nodeType == XMLReader::END_ELEMENT && $reader->localName == "text") { break; } } } } } return $lines; } //This function retrieves the stanzas in other editions corresponding to the stanza making the call. function getStanzas($file,$poem,$version,$divID,$highlight) { //call the getLines function if highlighting is set to on. if ($highlight == "true") { $lines = getLines($file,$version,$divID); } $reader = new XMLReader(); //initialize reader $reader->open($file); //open file //output a button to call the javascript hideStanzas function echo '
'; //move forward through the document, looking for the docEdition element node. For each, //if it's not the version calling the function, continue executing the function. while ($reader->read()) { if ($reader->nodeType == XMLReader::ELEMENT && $reader->localName == "docEdition") { $reader->read(); if ($reader->value != $version) { $thisversion = $reader->value; $foundmatch = "false"; //initialize $foundmatch variable to false. //start moving forward again; look for lg element node, grab its n //attribute value, and start building div boxes while ($reader->read()) { if ($reader->nodeType == XMLReader::ELEMENT && $reader->localName == "lg") { $stanzaID = $reader->getAttribute("n"); if ($stanzaID == $divID) { $foundmatch = "true"; //change $foundmatch variable to true echo '