当前位置: 首页>>代码示例>>PHP>>正文


PHP xml::parse方法代码示例

本文整理汇总了PHP中xml::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP xml::parse方法的具体用法?PHP xml::parse怎么用?PHP xml::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml的用法示例。


在下文中一共展示了xml::parse方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: XML_unserialize

function XML_unserialize($xml)
{
    $xml_parser = new xml();
    $data = $xml_parser->parse($xml);
    $xml_parser->destruct();
    return $data;
}
开发者ID:yunsite,项目名称:tp-coupon,代码行数:7,代码来源:Xml.class.php

示例2: parse

 static function parse($node, $allow = null, $deny = null)
 {
     $find = array();
     $replace = array();
     foreach (self::$find as $n => $rule) {
         list($code, $expression) = $rule;
         $allowed = !$allow || $allow && in_array($code, $allow);
         $denied = $deny && in_array($code, $deny);
         if ($allowed && !$denied) {
             $find[] = $expression;
             $replace[] = self::$replace[$n];
         }
     }
     $xml = new xml();
     foreach ($node->children() as $child) {
         $xml->append($xml->import($child));
     }
     foreach ($xml->query('//text()') as $text) {
         $parent = $text->parent();
         $bbcode = preg_replace($find, $replace, $text->value());
         $bbcode = xml::parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><bbcode>{$bbcode}</bbcode>");
         foreach ($bbcode->query('/bbcode/* | /bbcode/text()') as $child) {
             $parent->insert($xml->import($child), $text);
         }
         $parent->remove($text);
     }
     return $xml;
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:28,代码来源:bbcode.php

示例3: to_xml

 private function to_xml($result)
 {
     switch ($this->content_type) {
         case 'xml':
             return xml::parse($result);
         case 'json':
             return xml::json($this->root[0], $result);
         default:
             runtime_error('Unknown HTTP procedure content type: ' . $this->content_type);
     }
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:11,代码来源:http_procedure.php

示例4: clean

 public static function clean($xml, $allowed = FALSE, $debug = FALSE)
 {
     if (!($tree = xml::parse("<wrapper>{$xml}</wrapper>"))) {
         return FALSE;
     }
     if (!$allowed) {
         $allowed = array('a' => array('attributes' => array('href' => 'URL', 'title' => '/^([ \\-_a-zA-Z0-9\\.\\/\\!]+)$/')), 'img' => array('attributes' => array('src' => 'URL', 'title' => 'ANY', 'alt' => 'ANY')), 'b' => array('transform' => 'strong'), 'i' => array('transform' => 'em'), 'strong' => array(), 'em' => array(), 'p' => array());
     }
     if (is_array($tree)) {
         $tree = self::clean_childnodes($tree, $allowed);
         // If not in debug mode return XML
         if (!$debug) {
             return xml::build($tree);
         } else {
             return $tree;
         }
     } else {
         return FALSE;
     }
 }
开发者ID:reang,项目名称:Dingo-Framework,代码行数:20,代码来源:xss.php

示例5: parse

        xml_set_object($this->parser, $this);
        xml_set_element_handler($this->parser, "tag_open", "tag_close");
        xml_set_character_data_handler($this->parser, "cdata");
    }
    function parse($data)
    {
        xml_parse($this->parser, $data);
    }
    function tag_open($parser, $tag, $attributes)
    {
        var_dump($parser, $tag, $attributes);
    }
    function cdata($parser, $cdata)
    {
        var_dump($parser, $cdata);
    }
    function tag_close($parser, $tag)
    {
        var_dump($parser, $tag);
    }
}
// end of class xml
$xml_parser = new xml();
$xml_parser->parse("<A ID='hallo'>PHP</A>");
?>
</pre>
<?php 
require_once '../../includes/footer.php';
?>

开发者ID:pixlr,项目名称:zce-1,代码行数:29,代码来源:xml_set_object.php

示例6: IPplanIPTemplate

 function IPplanIPTemplate($name, $cust = 0, $netaddr = FALSE)
 {
     $filename = $this->__findtemp($name, $cust, $netaddr);
     if ($filename == FALSE) {
         return;
     }
     // suppress errors when loading file
     if (!($data = @file($filename))) {
         $this->error = TRUE;
         $this->errmsg = "Error reading template file";
         if (DEBUG) {
             echo $this->errmsg;
         }
         return;
     }
     $input = implode("", $data);
     require_once "../xmllib.php";
     $xml_parser = new xml("FIELD");
     if (!$xml_parser->parser) {
         $this->error = TRUE;
         $this->errmsg = "Error opening XML parser";
         if (DEBUG) {
             echo $this->errmsg;
         }
         return 1;
         // parser not initialized - XML probably not compiled in
     }
     $output = $xml_parser->parse($input);
     if (!$output) {
         $this->error = TRUE;
         $this->errmsg = "Error parsing XML file";
         if (DEBUG) {
             echo $this->errmsg;
         }
         return 1;
         // not XML format
     }
     // turn on line below for debugging
     //echo "<pre>"; var_dump($output); echo "</pre>";
     foreach ($output as $key => $value) {
         $field = $value["DEFINITION"]["NAME"];
         // field names must be alpha numeric with no spaces etc, else row is ignored!
         if (!empty($field) and preg_match("/^[a-zA-Z0-9]+\$/", $field)) {
             $this->userfld["{$field}"]["descrip"] = isset($value["DEFINITION"]["DESCRIP"]) ? $value["DEFINITION"]["DESCRIP"] : "Field: " . $field;
             // selectbox?
             if ($this->__selectbox($value, $field)) {
                 continue;
             }
             // checkbox?
             //else if ($this->__checkbox($value, $field)) {
             //    continue;
             //}
             // use default type of character - all bogus fields are converted to character
             $this->__character($value, $field);
         }
     }
     //echo "<pre>";var_dump($this->userfld);echo "</pre>";
     return;
 }
开发者ID:hetznerZA,项目名称:ipplan,代码行数:59,代码来源:class.templib.php

示例7: xml

 private function xml($xml, $name, $value)
 {
     return $xml->import(xml::parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><{$name}>{$value}</{$name}>")->root());
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:4,代码来源:procedure.php

示例8: callService

    /**********************************************************/
    /* Web service internals */
    /**********************************************************/
    function callService($methodCall)
    {
        // PHP 4 version requires PEAR
        //		require_once "HTTP/Request.php";
        //		$req =& new HTTP_Request($this->apiNode.'?apikey='.rawurlencode($this->apiKey).'&method='.$methodCall);
        //		$req->addHeader("User-Agent", $this->userAgent);
        //		$response = $req->sendRequest();
        try {
            $handle = fopen($this->apiNode . '?v=' . rawurlencode($this->version) . '&apikey=' . rawurlencode($this->apiKey) . '&method=' . $methodCall . '&cloudid=' . SITE_CLOUDID, "rb");
            $resp = stream_get_contents($handle);
            /*	PHP 4.x version
			$resp = '';
			while (!feof($handle)) {
			  $resp .= fread($handle, 8192);
			}
			*/
            fclose($handle);
        } catch (Exception $e) {
            echo 'Caught exception: ', $e->getMessage(), "\n";
            return false;
        }
        //		if (PEAR::isError($response)) {
        //			return FALSE;
        //		} else {
        // $resp=$req->getResponseBody();
        require_once 'xml.php';
        $xml_parser = new xml(false, true, true);
        $parsed_response = $xml_parser->parse($resp);
        $temp = new stdClass();
        if ($parsed_response['response']['result'] == 'ok') {
            $temp->result = true;
        } else {
            $temp->result = false;
            $temp->message = $parsed_response['response']['message'];
            $this->db->log('API error: ' . $methodCall . ' returned ' . $temp->message);
        }
        $temp->response = $parsed_response['response'];
        $this->final = array();
        $callback[] =& $this;
开发者ID:smbale,项目名称:open-social-media-toolkit,代码行数:42,代码来源:apiCloud.class.php

示例9: xml

class xml
{
    var $parser;
    function xml()
    {
        $this->parser = xml_parser_create();
        xml_set_object($this->parser, $this);
        xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
        xml_set_character_data_handler($this->parser, 'cdata');
    }
    function parse($data)
    {
        xml_parse($this->parser, $data);
    }
    function tag_open($parser, $tag, $attributes)
    {
        var_dump($tag, $attributes);
    }
    function cdata($parser, $cdata)
    {
        var_dump($cdata);
    }
    function tag_close($parser, $tag)
    {
        var_dump($tag);
    }
}
$xml_parser = new xml();
$xml_parser->parse('<A ID="hallo">PHP</A>');
开发者ID:badlamer,项目名称:hhvm,代码行数:29,代码来源:1667.php

示例10: parse

 /**
  * Parses a string by a set of available methods
  *
  * Available methods:
  * - json
  * - xml
  * - url
  * - query
  * - php
  *
  * <code>
  *
  * str::parse('{"test":"cool","super":"genious"}');
  * // output: array(
  * //  'test' => 'cool',
  * //  'super' => 'genious'
  * // );
  *
  * str::parse('<xml><entries><cool>nice</cool></entries></xml>', 'xml');
  * // output: array(
  * //    'entries' => array(
  * //        'cool' => 'nice'
  * //    )
  * // );
  *
  * </code>
  *
  * @param  string  $string
  * @param  string  $mode
  * @return string
  */
 public static function parse($string, $mode = 'json')
 {
     if (is_array($string) or is_object($string)) {
         return $string;
     }
     switch ($mode) {
         case 'json':
             return (array) @json_decode($string, true);
             break;
         case 'xml':
             return xml::parse($string);
             break;
         case 'url':
             return (array) @parse_url($string);
             break;
         case 'php':
             return @unserialize($string);
             break;
         default:
             return $string;
             break;
     }
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:54,代码来源:str.php

示例11: xml

$data = '<document>
   <bank name="Kazkommertsbank JSC">
      <customer name="John Cardholder" mail="klient@mymail.com" phone="223322">
         <merchant cert_id="7269C18D00010000005E" name="Shop Name">
            <order order_id="000282" amount="3100" currency="398">
               <department merchant_id="90028101" amount="1300" rl=ASDFG" />
            </order>
         </merchant>
         <merchant_sign type="RSA/">
      </customer>
      <customer_sign type="SSL">
         4817C411000100000084
         </customer_sign>
      <results timestamp="2006-11-22 12:20:30 ">
         <payment merchant_id="90050801" amount="320.50" reference="109600746891" approval_code="730190" response_code="00" Secure="No" card_bin="KAZ" c_hash="6A2D7673A8EEF25A2C33D67CB5AAD091"/>
      </results>
   </bank>
   <bank_sign cert_id="14276668000100000028" type="SHA/RSA">
      JI3RZMEvexNlDmKsOQhe0pzHuKijnbhvnLu99qh7h+Ju8HvSfGNbEJxXUL58M94tXvu7w0BXSY7M
      HePGqz32JuMLAncuzyMwq845linW/sH/WvbZ+6SSYfxDMnvgX0S/pKxbhSXs7lGVBngXOwq7Bhsk
      8GcDUkWAM5UAsKpEKoI=
   </bank_sign>
</document>';
include "/home/majesty/projects/kolesa.kz/lib/kkb/kkb.utils.php";
$parser = new xml();
$result = $parser->parse($data);
var_dump($result);
if (in_array("DOCUMENT", $result)) {
    var_export(split_sign($data, "BANK"));
}
开发者ID:iborodikhin,项目名称:kazkom-epay,代码行数:30,代码来源:test.php

示例12: returnParsedXMLPost

function returnParsedXMLPost($docURL, $postVars)
{
    $url = $docURL;
    $user_agent = "Mozilla/5.0 (Macintosh; U; PPC Mac OSX; en-us)";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
    $xmlResults = curl_exec($ch);
    curl_close($ch);
    $xml_parser = new xml(false, true, true);
    $parsed_response = $xml_parser->parse($xmlResults);
    return $parsed_response;
}
开发者ID:njoubert,项目名称:UndergraduateProjects,代码行数:19,代码来源:eventInfo.php


注:本文中的xml::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。