/** * Appeand xml to testplan at specified path. * * @param array $list list of xpath and value for replacement. * @param string $xml (optional) appeand xml. * @param string $insertnodepath insert node xpath. * @param bool $debug useful when debugging new tag xml. */ private static function replace_append_xml_in_testplan($list, $xml = '', $insertnodepath = '', $debug = false) { $dom = new \DOMDocument(); $dom->load(util::get_testplan_file_path(true)); if (!empty($xml)) { $xmldom = self::replace_variables($list, $xml); } else { $dom = self::replace_variables($list, $dom); } if (!empty($xmldom)) { $xmldomxpath = new \DOMXPath($dom); $query = $xmldomxpath->query($insertnodepath); $importednode = $dom->importNode($xmldom->documentElement, TRUE); if ($debug) { var_dump($insertnodepath); var_dump($query); } $query->item(0)->appendChild($importednode); } $dom->save(util::get_testplan_file_path()); }