function xsl() { $this->data['title'] = 'Trends XSL'; $this->data['pagebody'] = 'vtrendsxsl'; //obtains view template data $this->load->helper('display'); //loads the helper functionality $this->data['myxml'] = display_file('./data/xml/energy.xml'); //displays the contents of the xml file in the myxml placeholder $this->data['xmltable'] = xsl_transform('./data/xml/energy.xml', './data/xml/energy.xsl'); $this->data['eproduced'] = xsl_transform('./data/xml/energy.xml', './data/xml/energy2.xsl'); $this->data['eused'] = xsl_transform('./data/xml/energy.xml', './data/xml/energy3.xsl'); $doc = new DOMDocument(); //$doc->validateOnParse = true; $doc->load('./data/xml/energy.xml'); $xml = XMLReader::open('./data/xml/energy.xml'); $xml->setSchema('./data/xml/energy.xsd'); // You must to use it $xml->setParserProperty(XMLReader::VALIDATE, true); libxml_use_internal_errors(true); if ($xml->isValid()) { $this->data['validatedxml'] = '<br/>XML Valid <br/><br/>'; } else { $result = "<b>ERROR</b><br/>"; foreach (libxml_get_errors() as $error) { $result .= $error->message . '<br/>'; } libxml_clear_errors(); $result .= '<br/>'; $this->data['validatedxml'] = $result; } $this->render(); //renders the page }
$tumblr_password = '******'; // Data for new record $num_posts = '50'; // Prepare POST request $request_data = http_build_query(array('email' => $tumblr_email, 'password' => $tumblr_password, 'num' => $num_posts)); // Send the POST request with cURL $c = curl_init('http://www.tumblr.com/api/dashboard'); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $request_data); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($c); $status = curl_getinfo($c, CURLINFO_HTTP_CODE); curl_close($c); // Check for success if ($status == 200) { xsl_transform($result); } else { echo "Error: {$result}\n"; } function xsl_transform($xml) { // load XML file $XML = new DOMDocument(); $XML->loadXML($xml); // XSL transform $xslt = new XSLTProcessor(); $XSL = new DOMDocument(); $XSL->load('tumblr-dashboard-rss.xsl', LIBXML_NOCDATA); $xslt->importStylesheet($XSL); echo $xslt->transformToXML($XML); }