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


PHP XML类代码示例

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


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

示例1: getXML

 /**
  * Loads the xml file into a string and returns this string.
  *  
  * @return 	XML		$xml
  */
 protected function getXML()
 {
     $instructions = $this->installation->getInstructions();
     if (!isset($instructions[$this->tagName]['cdata'])) {
         return false;
     }
     // Search the acpmenu xml-file in the package archive.
     // Abort installation in case no file was found.
     if (($fileIndex = $this->installation->getArchive()->getTar()->getIndexByFilename($instructions[$this->tagName]['cdata'])) === false) {
         throw new SystemException("xml file '" . $instructions[$this->tagName]['cdata'] . "' not found in '" . $this->installation->getArchive()->getArchive() . "'", 13008);
     }
     // Extract acpmenu file and parse with SimpleXML
     $xml = new XML();
     $tmpFile = FileUtil::getTemporaryFilename('xml_');
     try {
         $this->installation->getArchive()->getTar()->extract($fileIndex, $tmpFile);
         $xml->loadFile($tmpFile);
     } catch (Exception $e) {
         // bugfix to avoid file caching problems
         try {
             $this->installation->getArchive()->getTar()->extract($fileIndex, $tmpFile);
             $xml->loadFile($tmpFile);
         } catch (Exception $e) {
             $this->installation->getArchive()->getTar()->extract($fileIndex, $tmpFile);
             $xml->loadFile($tmpFile);
         }
     }
     @unlink($tmpFile);
     return $xml;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:35,代码来源:AbstractXMLPackageInstallationPlugin.class.php

示例2: unserialize

 public static function unserialize($xml, $isnormal = false)
 {
     $xml_parser = new XML($isnormal);
     $data = $xml_parser->parse($xml);
     $xml_parser->destruct();
     return $data;
 }
开发者ID:tenstone,项目名称:ucenter-client,代码行数:7,代码来源:SerializerXml.php

示例3: XML_unserialize

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

示例4: parseFeed

 /**
  * Parse a rss feed.
  * 
  * @param	string		$sourceURL
  * @return	array
  */
 public static function parseFeed($sourceURL)
 {
     $newsItems = array();
     $filename = FileUtil::downloadFileFromHttp($sourceURL, 'feed');
     // open & parse file
     $xml = new XML($filename);
     $data = $xml->getElementTree('channel');
     $items = $data['children'][0]['children'];
     foreach ($items as $item) {
         if ($item['name'] != 'item') {
             continue;
         }
         $newsItem = array('title' => '', 'author' => '', 'link' => '', 'guid' => '', 'pubDate' => '', 'description' => '');
         foreach ($item['children'] as $child) {
             if (!isset($child['cdata'])) {
                 continue;
             }
             $newsItem[$child['name']] = $child['cdata'];
         }
         // convert encodings
         if (CHARSET != 'UTF-8') {
             $newsItem['title'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['title']);
             $newsItem['author'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['author']);
             $newsItem['link'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['link']);
             $newsItem['guid'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['guid']);
             $newsItem['description'] = StringUtil::convertEncoding('UTF-8', CHARSET, $newsItem['description']);
         }
         @($newsItem['pubDate'] = intval(strtotime($newsItem['pubDate'])));
         $newsItems[] = $newsItem;
     }
     // delete tmp file
     @unlink($filename);
     return $newsItems;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:40,代码来源:FeedReaderSource.class.php

示例5: unapiExplainResponse

function unapiExplainResponse($unapiID)
{
    global $contentTypeCharset;
    // these variables are specified in 'ini.inc.php'
    $unapiCollectionDoc = new XMLDocument();
    $unapiCollectionDoc->setEncoding($contentTypeCharset);
    $unapiCollection = new XML("formats");
    if (!empty($unapiID)) {
        $unapiCollection->setTagAttribute("id", $unapiID);
    }
    // Recommended format names are given at <http://unapi.stikipad.com/unapi/show/existing+formats>
    // TODO: add 'ISI', 'ODF XML' and 'Word XML'
    addNewBranch($unapiCollection, "format", array("name" => "bibtex", "type" => "text/plain", "docs" => "http://en.wikipedia.org/wiki/BibTeX"), "");
    // function 'addNewBranch()' is defined in 'webservice.inc.php'
    addNewBranch($unapiCollection, "format", array("name" => "endnote", "type" => "text/plain", "docs" => "http://www.ecst.csuchico.edu/~jacobsd/bib/formats/endnote.html"), "");
    addNewBranch($unapiCollection, "format", array("name" => "ris", "type" => "text/plain", "docs" => "http://www.adeptscience.co.uk/kb/article/A626"), "");
    addNewBranch($unapiCollection, "format", array("name" => "atom", "type" => "application/atom+xml", "docs" => "http://www.atomenabled.org/developers/syndication/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "mods", "type" => "application/xml", "docs" => "http://www.loc.gov/standards/mods/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "oai_dc", "type" => "application/xml", "docs" => "http://www.openarchives.org/OAI/openarchivesprotocol.html#dublincore"), "");
    addNewBranch($unapiCollection, "format", array("name" => "srw_dc", "type" => "application/xml", "docs" => "http://www.loc.gov/standards/sru/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "srw_mods", "type" => "application/xml", "docs" => "http://www.loc.gov/standards/sru/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "html", "type" => "text/html", "docs" => "http://www.w3.org/MarkUp/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "rtf", "type" => "application/rtf", "docs" => "http://en.wikipedia.org/wiki/Rich_Text_Format"), "");
    addNewBranch($unapiCollection, "format", array("name" => "pdf", "type" => "application/pdf", "docs" => "http://partners.adobe.com/public/developer/pdf/index_reference.html"), "");
    addNewBranch($unapiCollection, "format", array("name" => "latex", "type" => "application/x-latex", "docs" => "http://en.wikipedia.org/wiki/LaTeX"), "");
    addNewBranch($unapiCollection, "format", array("name" => "markdown", "type" => "text/plain", "docs" => "http://daringfireball.net/projects/markdown/"), "");
    addNewBranch($unapiCollection, "format", array("name" => "text", "type" => "text/plain"), "");
    $unapiCollectionDoc->setXML($unapiCollection);
    $unapiCollectionString = $unapiCollectionDoc->getXMLString();
    return $unapiCollectionString;
}
开发者ID:Olari0,项目名称:Finugriling,代码行数:31,代码来源:unapi.inc.php

示例6: lCV3

 public function lCV3($id = -1, $returnCollector = true)
 {
     if ($this->Adapter == null) {
         $this->loadAdapter();
     }
     if ($this->xml == null and $this->collection != null) {
         if (is_object($this->collection)) {
             $this->collection->lCV3();
             $XML = new XML();
             $XML->setCollection($this->collection);
             $this->xml = $XML->getXML();
         } elseif (is_string($this->collection)) {
             $handle = @fopen($this->collection, "r");
             if ($handle) {
                 while (!feof($handle)) {
                     $this->xml .= fgets($handle, 4096);
                 }
                 fclose($handle);
             } else {
                 die('error');
             }
         }
     }
     $this->Adapter->setXML($this->xml);
     if ($returnCollector) {
         $this->collector = $this->Adapter->lCV4();
     } else {
         return $this->Adapter->lCV4();
     }
 }
开发者ID:nemiah,项目名称:trinityDB,代码行数:30,代码来源:XMLC.class.php

示例7: validate

 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // upload
     if ($this->optionImport && $this->optionImport['error'] != 4) {
         if ($this->optionImport['error'] != 0) {
             throw new UserInputException('optionImport', 'uploadFailed');
         }
         try {
             $xml = new XML($this->optionImport['tmp_name']);
             $optionsXML = $xml->getElementTree('options');
             foreach ($optionsXML['children'] as $option) {
                 $name = $value = '';
                 foreach ($option['children'] as $optionData) {
                     switch ($optionData['name']) {
                         case 'name':
                             $name = $optionData['cdata'];
                             break;
                         case 'value':
                             $value = $optionData['cdata'];
                             break;
                     }
                 }
                 if (!empty($name)) {
                     $this->options[$name] = $value;
                 }
             }
         } catch (SystemException $e) {
             throw new UserInputException('optionImport', 'importFailed');
         }
     } else {
         throw new UserInputException('optionImport');
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:37,代码来源:OptionImportAndExportForm.class.php

示例8: xml_unserialize

function xml_unserialize(&$xml, $isnormal = FALSE)
{
    $xml_parser = new XML($isnormal);
    $data = $xml_parser->parse($xml);
    $xml_parser->destruct();
    return $data;
}
开发者ID:saintho,项目名称:phpdisk,代码行数:7,代码来源:xml.class.php

示例9: set

 private function set($url)
 {
     $contents = file_get_contents($url);
     if ($contents) {
         $xml = new XML($contents);
         $this->json = json_encode($xml->get());
     }
 }
开发者ID:richtaur,项目名称:richtaur.com,代码行数:8,代码来源:rss.php

示例10: XML

function &XML_unserialize(&$xml)
{
    //$xml_parser = &new XML();
    $xml_parser = new XML();
    $data =& $xml_parser->parse($xml);
    $xml_parser->destruct();
    return $data;
}
开发者ID:aim-web-projects,项目名称:ann-cosme,代码行数:8,代码来源:_xml.php

示例11: xml_unserialize

function xml_unserialize(&$xml)
{
    $xml_parser = new XML();
    $data = $xml_parser->parse($xml);
    $xml_parser->destruct();
    $arr = xml_format_array($data);
    return $arr['root'];
}
开发者ID:dalinhuang,项目名称:shopexts,代码行数:8,代码来源:xml.class.php

示例12: leer

 function leer($oc)
 {
     session_start();
     //$xml_file="./demo.xml";
     $xml_file = "./OC/Orden_" . $oc . ".xml";
     #$xml_data=implode("",file($xml_file)); //get XML data for alternative direct parsing
     $xml = new XML();
     $xml->file_read($xml_file);
     #$xml->parse($xml_data); //parse direct XML data
     $xml->parse();
     #$xml->debug();
     //Samples...
     //echo $xml->demo->tag1->_param["say"];
     //echo $xml->demo->tag4->item[1]->_value;
     $_SESSION["numoc"] = $oc;
     $fecha = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderDates->PromiseDate->_value;
     $fechaoc = explode("T", $fecha);
     $_SESSION["fechaoc"] = $fechaoc[0];
     $_SESSION["depto"] = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->BuyerParty->NameAddress->Name1->_value;
     $rut = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->SellerParty->PartyID->Ident->_value;
     $r = explode(".", $rut);
     $rut2 = $r[0] . $r[1] . $r[2];
     $r2 = explode("-", $rut2);
     $_SESSION["rutp1"] = $r2[0];
     $_SESSION["rutp2"] = $r2[1];
     $_SESSION["namep"] = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->SellerParty->NameAddress->Name1->_value;
     $_SESSION["direccionp"] = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->SellerParty->NameAddress->District->_value;
     $_SESSION["ciudadp"] = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->SellerParty->NameAddress->City->_value;
     $_SESSION["contactop"] = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->SellerParty->PrimaryContact->ContactName->_value;
     $_SESSION["telefonop"] = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->SellerParty->PrimaryContact->ListOfContactNumber->ContactNumber[1]->ContactNumberValue->_value;
     $_SESSION["solicitante"] = $xml->OrdersResults->OrdersList->Order->OrderHeader->OrderParty->BuyerParty->PrimaryContact->ContactName->_value;
     $_SESSION["Total"] = $xml->OrdersResults->OrdersList->Order->OrderSummary->OrderTotal->MonetaryAmount->_value;
     $_SESSION["neto"] = $xml->OrdersResults->OrdersList->Order->OrderSummary->OrderSubTotal->MonetaryAmount->_value;
     $size = $xml->OrdersResults->OrdersList->Order->OrderSummary->NumberOfLines->_value;
     $_SESSION["size"] = $size;
     $list = array();
     if ($size == 1) {
         $name = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail->BaseItemDetail->ItemIdentifiers->ItemDescription->_value;
         $cantidad = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail->BaseItemDetail->TotalQuantity->QuantityValue->_value;
         $preciou = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail->PricingDetail->ListOfPrice->Price->UnitPrice->UnitPriceValue->_value;
         $preciot = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail->PricingDetail->LineItemTotal->MonetaryAmount->_value;
         $list[0] = array($name, $cantidad, $preciou, $preciot);
     } else {
         for ($i = 0; $i < $size; $i++) {
             $name = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail[$i]->BaseItemDetail->ItemIdentifiers->ItemDescription->_value;
             $cantidad = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail[$i]->BaseItemDetail->TotalQuantity->QuantityValue->_value;
             $preciou = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail[$i]->PricingDetail->ListOfPrice->Price->UnitPrice->UnitPriceValue->_value;
             $preciot = $xml->OrdersResults->OrdersList->Order->OrderDetail->ListOfItemDetail->ItemDetail[$i]->PricingDetail->LineItemTotal->MonetaryAmount->_value;
             $list[$i] = array($name, $cantidad, $preciou, $preciot);
         }
     }
     $_SESSION["list"] = $list;
     /*echo "<hr />";
     foreach($xml->demo->tag2->text as $key=>$value){
     	echo "$key = $value->_value<br />";
     }*/
 }
开发者ID:robertoesteban,项目名称:Sistema-de-Bodega,代码行数:57,代码来源:LeerXML.php

示例13: apply

 function apply(&$value, &$component)
 {
     $xml = new XML();
     $xml->parseXML($value);
     $rootNode = $xml->firstChild;
     $result = '';
     $this->__toString($rootNode, $result);
     $value = preg_replace('/^<root>/i', '', $result);
 }
开发者ID:GruppoMeta,项目名称:Movio,代码行数:9,代码来源:ForceNoTagText.php

示例14: ls

 public static function ls($url, array $loginDetails = array(), array $options = array())
 {
     $options['asXML'] = true;
     $output = self::executeCommand('list', $url, $loginDetails, $options);
     $output = implode($output, '');
     $xml = new XML();
     $xml->loadString($output);
     return $xml->getElementTree('');
 }
开发者ID:ZerGabriel,项目名称:PackageBuilder,代码行数:9,代码来源:Subversion.class.php

示例15: testSerialization

 function testSerialization()
 {
     $input = array(array('Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null), 'Style' => array('id' => null, 'name' => null), 'JobType' => array('id' => 1, 'name' => 'Touch Screen Kiosk'), 'Industry' => array('id' => 1, 'name' => 'Financial')), array('Project' => array('id' => 2, 'title' => null, 'client_id' => 2, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 2, 'industry_id' => 2, 'modified' => '2007-11-26 14:48:36', 'created' => null), 'Style' => array('id' => null, 'name' => null), 'JobType' => array('id' => 2, 'name' => 'Awareness Campaign'), 'Industry' => array('id' => 2, 'name' => 'Education')));
     $expected = '<project id="1" title="" client_id="1" show="1" is_spotlight="" style_id="0" job_type_id="1" industry_id="1" modified="" created=""><style id="" name="" /><job_type id="1" name="Touch Screen Kiosk" /><industry id="1" name="Financial" /></project><project id="2" title="" client_id="2" show="1" is_spotlight="" style_id="0" job_type_id="2" industry_id="2" modified="2007-11-26 14:48:36" created=""><style id="" name="" /><job_type id="2" name="Awareness Campaign" /><industry id="2" name="Education" /></project>';
     $xml = new XML($input);
     $result = $xml->compose(false);
     $result = preg_replace("/\n/", '', $result);
     $this->assertEqual($expected, $result);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:9,代码来源:xml.test.php


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