Jump to content

simplexml code error


novice_programmer

Recommended Posts

I would like to use the code attached, but my host does not support simplexml, it seems, but I have xslt loaded. can anyone help me with this so that I can use xslt instead if thats the right way to go about it.

 

 

The pieces to this can be found at this link:

http://www.phphacks.com/content/view/51/33/

 

 

 

<?php

 

// this class retrieves an RSS feed and performs a XSLT transformation

class CRssReader

{

  private $mXml;

  private $mXsl;

 

// Constructor - creates an XML object based on the specified feed

function __construct($szFeed)

{

  // retrieve the RSS feed in a SimpleXML object

  $this->mXml = simplexml_load_file(urldecode($szFeed));

  // retrieve the XSL file contents in a SimpleXML object

  $this->mXsl = simplexml_load_file('rss_reader.xsl');

}

 

// Creates a formatted XML document based on retrieved feed

public function getFormattedXML()

{

  // create the XSLTProcessor object

  $proc = new XSLTProcessor;

 

  // attach the XSL

  $proc->importStyleSheet($this->mXsl);

 

  // apply the transformation and return formatted data as XML string

  return $proc->transformToXML($this->mXml);

}

 

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/96931-simplexml-code-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.