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


PHP xml_parse_into_struct函数代码示例

本文整理汇总了PHP中xml_parse_into_struct函数的典型用法代码示例。如果您正苦于以下问题:PHP xml_parse_into_struct函数的具体用法?PHP xml_parse_into_struct怎么用?PHP xml_parse_into_struct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: parseSessions

function parseSessions($xml)
{
    $session_array = array();
    /* Parse the XML into tags */
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $xml, $values, $tags);
    xml_parser_free($parser);
    // loop through the structures
    foreach ($tags as $key => $value) {
        if ($key == "session") {
            $molranges = $value;
            // each contiguous pair of array entries are the
            // lower and upper range for each molecule definition
            for ($i = 0; $i < count($molranges); $i += 2) {
                $offset = $molranges[$i] + 1;
                $len = $molranges[$i + 1] - $offset;
                $session_array[] = parseSession(array_slice($values, $offset, $len));
            }
        } else {
            continue;
        }
    }
    return $session_array;
}
开发者ID:ptarcher,项目名称:exercise_mvc,代码行数:26,代码来源:FITSession.php

示例2: parseXML

function parseXML($xml)
{
    $parser = xml_parser_create();
    $output = array();
    xml_parse_into_struct($parser, $xml, $output);
    return $output;
}
开发者ID:Steadroy,项目名称:Dashboard,代码行数:7,代码来源:convio.php

示例3: __construct

 public function __construct($dataDirectory)
 {
     //
     // Default to English for lack of anything better
     //
     $this->clientLang = 'en-us';
     //
     // See if we can find anything better
     //
     $matches = array();
     if (array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
         setlocale(LC_ALL, 'en-US');
         if (preg_match('/(en-US|fr-FR|de-DE|it-IT|es-ES|sv-SV|sv-SE|nl-NL)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches)) {
             $this->clientLang = strtolower($matches[1]);
         }
     }
     //
     // Pull in all of the strings we need
     //
     $lang2file = array("es-es" => "es-ES.xml", "en-us" => "en-US.xml", "de-de" => "de-DE.xml", "fr-fr" => "fr-FR.xml", "it-it" => "it-IT.xml", "nl-nl" => "nl-NL.xml", "sv-sv" => "sv-SE.xml", "sv-se" => "sv-SE.xml");
     $xml_parser = xml_parser_create();
     $l10nValues = array();
     $l10nIndexes = array();
     $l10nContents = file_get_contents("{$dataDirectory}/" . $lang2file[$this->getClientLang()]);
     if (!xml_parse_into_struct($xml_parser, $l10nContents, $l10nValues, $l10nIndexes)) {
         die(sprintf("l10n: XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
     } else {
         foreach ($l10nIndexes["STRING"] as $l10nStringIndex) {
             $this->l10n[$l10nValues[$l10nStringIndex]["attributes"]["ID"]] = $l10nValues[$l10nStringIndex]["value"];
         }
     }
     xml_parser_free($xml_parser);
 }
开发者ID:roitiger,项目名称:sonosmusix,代码行数:33,代码来源:localizer.php

示例4: parseRSS

function parseRSS($url)
{
    //PARSE RSS FEED
    $feedeed = implode('', file($url));
    $parser = xml_parser_create();
    xml_parse_into_struct($parser, $feedeed, $valueals, $index);
    xml_parser_free($parser);
    //CONSTRUCT ARRAY
    foreach ($valueals as $keyey => $valueal) {
        if ($valueal['type'] != 'cdata') {
            $item[$keyey] = $valueal;
        }
    }
    $i = 0;
    foreach ($item as $key => $value) {
        if ($value['type'] == 'open') {
            $i++;
            $itemame[$i] = $value['tag'];
        } elseif ($value['type'] == 'close') {
            $feed = $values[$i];
            $item = $itemame[$i];
            $i--;
            if (count($values[$i]) > 1) {
                $values[$i][$item][] = $feed;
            } else {
                $values[$i][$item] = $feed;
            }
        } else {
            $values[$i][$value['tag']] = $value['value'];
        }
    }
    //RETURN ARRAY VALUES
    return $values[0];
}
开发者ID:rckarchitects,项目名称:cornerstone-rcka,代码行数:34,代码来源:inc_feeds.php

示例5: GetStatus

 function GetStatus($ip, $port, $pw)
 {
     error_reporting(0);
     $fp = fsockopen($ip, $port, $errno, $errstr, 1);
     if (!$fp) {
         error_reporting(E_ALL);
         $this->error = "{$errstr} ({$errno})";
         return 0;
     } else {
         error_reporting(E_ALL);
         socket_set_timeout($fp, 2);
         fputs($fp, "GET /stats?sid=1?pass=" . $pw . "&mode=viewxml HTTP/1.1\r\n");
         //  original --> admin.cgi?pass
         fputs($fp, "User-Agent: Mozilla\r\n\r\n");
         while (!feof($fp)) {
             $this->SHOUTcastData .= fgets($fp, 512);
         }
         fclose($fp);
         if (stristr($this->SHOUTcastData, "HTTP/1.1 200 OK") == true) {
             $this->SHOUTcastData = trim(substr($this->SHOUTcastData, 58));
         } else {
             $this->error = "Bad login";
             return 0;
         }
         $xmlparser = xml_parser_create('UTF-8');
         //xml_parse_into_struct($xmlparser, $this->SHOUTcastData, $this->values, $this->indexes);
         if (!xml_parse_into_struct($xmlparser, $this->SHOUTcastData, $this->values, $this->indexes)) {
             $this->error = "Unparsable XML";
             return 0;
         }
         xml_parser_free($this->values);
         return 1;
     }
 }
开发者ID:MichaelFichtner,项目名称:RadioLaFamilia,代码行数:34,代码来源:gr_radiostatus_class.php

示例6: parse

 public function parse($data)
 {
     $p = xml_parser_create();
     xml_parse_into_struct($p, $data, $vals, $index);
     xml_parser_free($p);
     return $vals;
 }
开发者ID:aurora-framework,项目名称:filesystem,代码行数:7,代码来源:XML.php

示例7: postToEWAY

 function postToEWAY($payment_id, $url, $vars)
 {
     global $db;
     $varsx = array();
     foreach ($vars as $k => $v) {
         $varsx[] = urlencode($k) . "=" . urlencode($v);
     }
     $result = get_url($url = $url . "?" . join('&', $varsx));
     $payment = $db->get_payment($payment_id);
     $payment['data'][] = $vars;
     $payment['data'][] = array('result' => $result);
     // Simple parser
     $parser = xml_parser_create();
     xml_parse_into_struct($parser, $result, $vals, $index);
     xml_parser_free($parser);
     foreach ($index as $k => $v) {
         foreach ($v as $vv) {
             if ($vals[$vv]['value']) {
                 $ret[$k] = $vals[$vv]['value'];
             }
         }
     }
     $payment['data'][] = $ret;
     $db->update_payment($payment_id, $payment);
     return $ret;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:26,代码来源:eway_international.inc.php

示例8: processXML

function processXML($filename)
{
    // read the xml document
    $data = implode("", file($filename));
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $data, $values, $tags);
    xml_parser_free($parser);
    $talks = array();
    // loop through the structures
    foreach ($tags as $key => $val) {
        if ($key == "talk") {
            $ranges = $val;
            $nranges = count($ranges);
            // each contiguous pair of array entries are the
            // lower and upper range for each talk elements
            for ($i = 0; $i < $nranges; $i += 2) {
                $offset = $ranges[$i] + 1;
                $len = $ranges[$i + 1] - $offset;
                $talks[] =& parseTalk(array_slice($values, $offset, $len));
            }
        } else {
            continue;
        }
    }
    return $talks;
}
开发者ID:SandyS1,项目名称:presentations,代码行数:28,代码来源:rss_create.php

示例9: xmlParse

function xmlParse($data, $bList = "")
{
    $bArray = array();
    // if any attributes were passed to the function, add them to the array
    if (strlen($bList) > 0) {
        $bArray = explode(",", $bList);
    }
    // by: waldo@wh-e.com - trim space around tags not within
    $data = eregi_replace(">" . "[[:space:]]+" . "<", "><", $data);
    // XML functions
    $p = xml_parser_create();
    // by: anony@mous.com - meets XML 1.0 specification
    xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
    xml_parse_into_struct($p, $data, $vals, $index);
    xml_parser_free($p);
    for ($x = 0; $x < count($vals); $x++) {
        if (array_key_exists("attributes", $vals[$x])) {
            foreach ($vals[$x]["attributes"] as $thiskey => $thisvalue) {
                // if the attribute name exists in the "bList" then re-cast the string to a boolean
                if (is_string($thisvalue) && array_search($thiskey, $bArray) !== false && (strtolower($thisvalue) == "true" || strtolower($thisvalue) == "false")) {
                    $vals[$x]["attributes"][$thiskey] = strtolower($thisvalue) == "true";
                }
            }
        }
    }
    $i = 0;
    $tree["xmlChildren"] = array();
    $tree["xmlChildren"][] = array('xmlName' => $vals[$i]['tag'], 'xmlAttributes' => getAttributes($vals, $i), 'xmlValue' => getValue($vals, $i), 'xmlChildren' => GetChildren($vals, $i));
    return $tree;
}
开发者ID:rodionbykov,项目名称:zCMS,代码行数:30,代码来源:fusebox4.loader.php4.php

示例10: GetXMLTree

function GetXMLTree($data) {
 
 // $data = implode('', file($file));
 // by: waldo@wh-e.com - trim space around tags not within
 
 //$data = eregi_replace(">"."[[:space:]]+"."<","><",$data);
 $data = preg_replace('/>\s+</', '><', $data);
 // XML functions
 $p = xml_parser_create();
 
 // by: anony@mous.com - meets XML 1.0 specification
 xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
 
 xml_parse_into_struct($p, $data, &$vals, &$index);
 
 xml_parser_free($p);
 
 $i = 0;
 $tree = array();
 $tree[] = array(
  'tag' => $vals[$i]['tag'], 
  'attributes' => $vals[$i]['attributes'], 
  'value' => $vals[$i]['value'], 
  'children' => GetChildren($vals, $i)
 );
 //debmes('xmltree - step 6');
 return $tree;
}
开发者ID:novozhenets,项目名称:majordomo,代码行数:28,代码来源:xml.class.php

示例11: pfp_resize_image

function pfp_resize_image($image_tag, $height, $width)
{
    $final_image_tag = $image_tag;
    $parser = xml_parser_create();
    xml_parse_into_struct($parser, $image_tag, $values);
    foreach ($values as $key => $val) {
        if ($val['tag'] == 'IMG') {
            $image_url = $val['attributes']['SRC'];
            break;
        }
    }
    //echo "height: " . $height;
    if ($height != '' && $width != '') {
        $final_image_tag = "<img src=" . $image_url . " style='width:" . $width . "px" . ";height:" . $height . "px" . "' />";
        //echo "1";
    } else {
        if ($height != '') {
            $final_image_tag = "<img src=" . $image_url . " style='height:" . $height . "px" . "' />";
            //echo "2";
        } else {
            if ($width != '') {
                $final_image_tag = "<img src=" . $image_url . " style='width:" . $width . "px" . "' />";
                //echo "3";
            }
        }
    }
    return $final_image_tag;
}
开发者ID:kevintrogers,项目名称:justbkause,代码行数:28,代码来源:posts-for-page.php

示例12: xmlize

function xmlize($data, $WHITE=1)
{

    $data = trim($data);
    $vals = $index = $array = array();
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $WHITE);
    if ( !xml_parse_into_struct($parser, $data, $vals, $index) ) {
	die(sprintf("XML error: %s at line %d",
		    xml_error_string(xml_get_error_code($parser)),
		    xml_get_current_line_number($parser)));

    }
    xml_parser_free($parser);

    $i = 0;

    $tagname = $vals[$i]['tag'];
    if ( isset ($vals[$i]['attributes'] ) ) {
	$array[$tagname]['@'] = $vals[$i]['attributes'];
    } else {
	$array[$tagname]['@'] = array();
    }

    $array[$tagname]["#"] = xml_depth($vals, $i);

    return $array;
}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:29,代码来源:class.xmlize.php

示例13: GetXMLTree

function GetXMLTree($xmldata)
{
    // we want to know if an error occurs
    ini_set('track_errors', '1');
    $xmlreaderror = false;
    $parser = xml_parser_create('ISO-8859-1');
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    if (!xml_parse_into_struct($parser, $xmldata, $vals, $index)) {
        $xmlreaderror = true;
        $err = PEAR::raiseError("XML Read error", 1, E_USER_WARNING, null, "Could not parse xml into structure.");
        return $err;
    }
    xml_parser_free($parser);
    if (!$xmlreaderror) {
        $result = array();
        $i = 0;
        $attributes = array();
        if (isset($vals[$i]['attributes'])) {
            foreach (array_keys($vals[$i]['attributes']) as $attkey) {
                $attributes[$attkey] = $vals[$i]['attributes'][$attkey];
            }
        }
        $result[$vals[$i]['tag']] = array_merge($attributes, GetChildren($vals, $i, 'open'));
    }
    ini_set('track_errors', '0');
    return $result;
}
开发者ID:minger11,项目名称:Pipeline,代码行数:28,代码来源:xml2array.php

示例14: parse_file

function parse_file()
{
    if (file_exists('japancar_krasnoyarsk.xml')) {
        $data = implode("", file('japancar_krasnoyarsk.xml'));
        $parser = xml_parser_create();
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
        xml_parse_into_struct($parser, $data, $values, $tags);
        xml_parser_free($parser);
        // проход через структуры
        foreach ($tags as $key => $val) {
            if ($key == "data") {
                $molranges = $val;
                // каждая смежная пара значений массивов является верхней и
                // нижней границей определения
                for ($i = 0; $i < count($molranges); $i += 2) {
                    $offset = $molranges[$i] + 1;
                    $len = $molranges[$i + 1] - $offset;
                    $tdb[] = parseString(array_slice($values, $offset, $len));
                }
            } else {
                continue;
            }
        }
        return $tdb;
    } else {
        exit('Не удалось открыть файл japancar_krasnoyarsk.xml.');
    }
}
开发者ID:balamyt92,项目名称:torrens_xml_converter,代码行数:29,代码来源:parse.php

示例15: XmlReader

 /**
  * reads an xml file, parses it into a structure
  * constructor
  * @param String file the xml file to read
  * @return XmlReader
  * @access public
  */
 function XmlReader($file)
 {
     $requested_file = $file;
     #the given path can be a absolute path
     #if it's not a file, look in the default CMS xml directory and the default xml directory for the given file
     if (is_file($file)) {
         $file = file($file);
     } elseif (is_file(CMS_XML_PATH . $file)) {
         $file = file(CMS_XML_PATH . $file);
     } else {
         $file = file(XML_PATH . $file);
     }
     #if the file still does not exist, raise error
     if (!is_array($file)) {
         new ErrorHandler(get_class($this), "constructor", "", "FILE DOES NOT EXIST", "The file does not exist: {$requested_file}");
     }
     $parser = xml_parser_create('ISO-8859-1');
     $data = implode($file, "");
     #this is how a complete node looks like, when unnecessary data is excluded:
     #Array ( [tag] => PAGE [type] => open [level] => 2 [value] => [node] => 1 )
     #Array ( [tag] => PAGENAME [type] => complete [level] => 3 [value] => billing [node] => 2 )
     #Array ( [tag] => PAGERIGHT [type] => complete [level] => 3 [value] => all [node] => 3 )
     #Array ( [tag] => PAGEAUTHORIZE [type] => complete [level] => 3 [value] => 0 [node] => 4 )
     #Array ( [tag] => PAGETITLE [type] => complete [level] => 3 [value] => Billing [node] => 5 )
     #Array ( [tag] => PAGEFRAME [type] => complete [level] => 3 [value] => body [node] => 6 )
     #Array ( [tag] => PAGEDEFAULT [type] => complete [level] => 3 [value] => 0 [node] => 7 )
     #Array ( [tag] => PAGE [type] => close [level] => 2 [node] => 8 )
     xml_parse_into_struct($parser, $data, $struct);
     $this->_struct = $struct;
     #exclude every array where the key is "type" and the value is "cdata"
     #for more details see the function exclude()
     $this->_excluded = $this->exclude('type', 'cdata');
 }
开发者ID:srookhuizen,项目名称:nedernesia,代码行数:40,代码来源:XmlReader.php


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