function testXMLProcessing() { $xml = new XMLtoArray("jobSpecification.xml"); $this->assertNoErrors($xml->directory = "../specifications/xml/"); $xmldata = '<?xml version="1.0" encoding="UTF-8"?>'; $this->assertNotNull($xml->process()); $this->assertNotNull($xml->stackSize()); }
function updateDatabases($xmlPackage, $workflowId, $formData, $goal) { global $db; $db = connect($xmlPackage->getDb()); debug::message("connect to db:" . $xmlPackage->getDb() . '<br>'); $newDataItem = new coreWorkflowDataPacket($workflowId, array()); $tables = $xmlPackage->getTables(); if (sizeof($tables) > 0) { //For each table for ($tableIndex = 0; $tableIndex < sizeof($tables); $tableIndex++) { $table = $tables[$tableIndex]->getTableName(); $valsArray['workflowId'] = $workflowId; $fields = $tables[$tableIndex]->getDbFields(); //The fields specificed for ($index = 0; $index < sizeof($fields); $index++) { $field = $fields[$index]; $valsArray[$field] = addslashes($formData[$field]); } //Does this workflow item already exist in the table $sql_query = "workflowId='{$workflowId}'"; if (dbpear::numRecords($table, "{$sql_query}")) { $keyName = dbs::getprimarykey($table); $keyValue = dbpear::selAttribute($keyName, $table, $sql_query); dbs::updaterecord($table, $valsArray, $keyName, $keyValue); } else { dbs::irrecord($table, $valsArray, false); } $db = connect('iWFMS'); } $xmlParser = new XMLtoArray("jobSpecification.xml"); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); if (!$goal) { //We are not at the goal node //Display the data as HTML xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item'); } else { //We are at the goal node xmlPackage::displayArchiveItem($xmlPackage, $workflowId, 'workflowArchive', 'Current archived workflow item', 'archive'); } } else { $xmlParser = new XMLtoArray("jobSpecification.xml"); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); //Display the data as HTML xmlPackage::displayItem($xmlPackage, $workflowId, 'workflow', 'Current workflow item'); } }
function databaseActions($databaseActions) { if (sizeof($databaseActions)) { //The form required data to be fetched from the database for ($index = 0; $index < sizeof($databaseActions); $index++) { $predicateValues = $databaseActions[$index]->getPredicateValues(); $xmlfile = $predicateValues[0]->toString() . '.xml'; $xmlParser = new XMLtoArray($xmlfile); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); //Display the data as HTML xmlPackage::displayAllData($xmlPackage, $_GET['workflowID'], 'Database Information'); } } }
/** * @return array representing XML file contents * @desc Reads the xml file in and parses it */ function process() { $count = 0; debug::message("XML spec: " . $this->file . '<br>'); $fp = XMLtoArray::openXML(); while ($data = fread($fp, 4096)) { debug::message("\n" . $data . "\n"); $this->parse($data); $count = $count - 1; } return $this->stack; }
} else { } $plannerProgress = $newPlannerProgress; $newPlannerProgress = array(); } } } debug::message("edge progression test :" . $edgeProgressionResult); if ($edgeProgressionResult) { if (!$goal) { //No point in updating plans if we have reached the goal planningAgent::updatePlans($plans); } $xmlParser = new XMLtoArray($_POST['formName'] . '.xml'); $xmlTree = $xmlParser->process(); //Package the xml data into objects $xmlPackage = xmlPackage::package($xmlTree); //Display the data as HTML xmlDatabase::updateDatabases($xmlPackage, $_POST['workflowID'], $_POST, $goal); } else { //no progress errors::errorMessage("Progression to a new workflow stage failed!"); $xmlParser = new XMLtoArray("jobSpecification.xml"); $xmlTree = $xmlParser->process(); //Package the xml data $xmlPackage = xmlPackage::package($xmlTree); //Display the data as HTML xmlPackage::displayItem($xmlPackage, $_POST['workflowID'], 'workflow', 'Current workflow item'); } } include_once "includes/commonPages/system_footer.php";
$url = 'http://www.whoisxmlapi.com/whoisserver/WhoisService?domainName=' . $domain . '&username='******'&password='******'&outputFormat=' . $format; if ($format == 'JSON') { ///////////////////////// // Use a JSON resource // ///////////////////////// // Get and build the JSON object $result = json_decode(file_get_contents($url)); // Print out a nice informative string print "<div>JSON:</div>" . RecursivePrettyPrint($result); } else { //////////////////////// // Use a XML resource // //////////////////////// $url = 'http://www.whoisxmlapi.com/whoisserver/WhoisService?domainName=' . $domain . '&username='******'&password='******'&outputFormat=' . $format; // Get and build the XML associative array $parser = new XMLtoArray(); $result = array("WhoisRecord" => $parser->ParseXML($url)); // Print out a nice informative string print "<div>XML:</div>" . RecursivePrettyPrint($result); } // Function to recursively print all properties of an object and their values function RecursivePrettyPrint($obj) { $str = ""; foreach ((array) $obj as $key => $value) { if (!is_string($key)) { // XML parsing leaves a little to be desired as it fills our obj with key/values with just whitespace, ignore that whitespace at the cost of losing hostNames and ips in the final printed result continue; } $str .= '<div style="margin-left: 25px;border-left:1px solid black">' . $key . ": "; if (is_string($value)) {