Questions about this topic? Sign up to ask in the talk tab.

Projects:Overview

From NetSec
Revision as of 14:33, 4 June 2012 by LashawnSeccombe (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Current Projects

XML Parser Class

 
<?PHP
// Z - [email protected]
// Requires: PHP5, cURL, SimpleXML
 
$a = new XMLParser('http://www.google.com/sitemap.xml') or die("Invalid XML Data");
 
class XMLParser {
 
  public  $xmldata;
  private $url = '';
 
  public function __construct($strURL = '') {
    $this->url = (strlen($strURL) ? $strURL : FALSE);
    $this->xmldata = ($this->url ? $this->getXML($this->url) : FALSE);
    return $this->xmldata;
  }
 
  public function getXML($xURL) {
    $ch = curl_init($xURL);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $localXML = simplexml_load_string(curl_exec($ch));
    curl_close($ch);
    return $localXML;
  }
}