Ejemplo n.º 1
0
 /**
  * Create a new parser instance.
  *
  * @throws Exception if there is no basic xml support in your PHP installation.
  */
 public function __construct()
 {
     if (self::$libxmlHasFlagSupport === false) {
         if (!extension_loaded('libxml')) {
             throw new Exception('The libxml extension is not loaded');
         }
         if (!extension_loaded('SimpleXML')) {
             throw new Exception('The SimpleXML extension is not loaded');
         }
         self::$libxmlHasFlagSupport = version_compare(phpversion(), '5.1') != -1 && defined('LIBXML_VERSION');
     }
 }
Ejemplo n.º 2
0
 /**
  * gets svn info on the provided path from the remote repo
  * returns the info in a SimpleXMLExtended object, with the hierarchy:
  *
  * entry /
  *  (attributes: kind, path, revision)
  *  url
  *  repository /
  *   root
  *   uuid
  *  commit /
  *   (attributes: revision)
  *   author
  *   date
  *
  * @param string $svnPath SVN path to retrieve (i.e. "tags/2011-03-30_00-00-00")
  * @throws SubversionToolsException
  * @return SimpleXMLExtended commit metadata
  */
 public function getPathInfo($svnPath)
 {
     $this->_validateSvnConfig();
     $user = escapeshellarg($this->svnUsername);
     $pw = escapeshellarg($this->svnPassword);
     $svnPath = trim($svnPath, '/');
     $svn = "svn info --xml --username {$user} --password {$pw} {$this->svnRepository}/{$svnPath}";
     $this->Logger->debug($svn);
     $rawPathInfo = trim(shell_exec($svn));
     $this->Logger->debug($rawPathInfo);
     try {
         $parsedPathInfo = $this->SimpleXMLParser->parseXMLString($rawPathInfo);
         if (!isset($parsedPathInfo->entry)) {
             throw new Exception();
         }
     } catch (Exception $e) {
         throw new SubversionToolsException('Path not found in repository!');
     }
     return $parsedPathInfo;
 }
 /**
  * @dataProvider getInvalidXmls
  * @expectedException \SimpleXMLParserException
  *
  * @param string $string
  */
 public function testParseBadXMLString($string)
 {
     $doc = $this->parser->parseXMLString($string);
 }
Ejemplo n.º 4
0
Archivo: Utils.php Proyecto: rsms/phpab
 /**
  * Convenience function to load a xml file into an array
  * 
  * @param  string
  * @return array XMLDOM
  * @deprecated Will be removed in future version. Considering using the convenience functions provided by {@link SimpleXMLParser}
  */
 public static function loadXML($file)
 {
     $xp = new SimpleXMLParser();
     $xp->loadFile($file);
     return $xp->toArray();
 }