onsfile_get_contents

file_get_contents  时间:2021-05-19  阅读:()
CopyrightIBMCorporation2010TrademarksSimulateXQueryandXIncludefunctionalitywithPHPPage1of8SimulateXQueryandXIncludefunctionalitywithPHPEnjoythepowerofXMLdataprocessinginwebprogrammingColinBeckinghamSeptember21,2010ManybrowserscanhandleXMLingeneral,butarecurrentlyweakintheirsupportofXQueryandXInclude.
YouneedtoworkaroundthisissuewhenyoubuildwebapplicationsthatcombineandprocessXML-structureddatafrommultiplesources.
UsingPHPisonesolution.
ThisarticlefirstshowshowyourwebpagescandeliverdataextractsfromXMLusingXQueryandXIncludeexplicitly,andthenhowtodotheequivalentworkwithPHP,allwithinthecontextofacooperativeeffortamonggardencenters.
XIncludeandXQueryareXMLtoolsthathelpwebprogrammersprocessdatadynamically.
XIncludeletsyoutreatmultipleXMLfilesasiftheywereonefile,andXQuerycanprocessthecombineddataandprepareitforinclusionintooutputforweb-pagedisplay.
Together,theyperformthisserviceelegantlyandefficientlywithfewlinesofcode.
FrequentlyusedacronymsHTTP:HypertextTransferProtocolW3C:WorldWideWebConsortiumXHTML:ExtensibleHypertextMarkupLanguageXML:ExtensibleMarkupLanguageXSL:ExtensibleStylesheetLanguageMostbrowserscandisplayandprocessXMLfileseitherdirectlyorincooperationwithXSLtemplates.
Inanidealworld,browserswouldunderstandXQueryandXIncludedirectlytoo.
Butatthispointtheysupportthesetoolsonlybyplacingunreasonabledemandsonusers—forexample,byrequiringthemtoloadexperimentaladd-ons.
Fetchingthedatafromwidelydifferentsourcesandcombiningthemintoonelargedatasetforprocessingcanbeapainstakingtaskforthewebprogrammer.
Throughahypotheticalbusinessexample,thisarticlefirstshowsyouthestrengthofthecombinationofXQueryandXInclude.
Thenyou'lllearnhowtousePHPtosimulatethefunctionalitythatXQueryandXIncludeprovide.
MovingallthedataprocessingtotheserversidegivesyouaworkaroundtolimitedbrowsersupportforXQueryandXInclude.
AnotherbenefitisthatPHPgivesyoumuchfinercontroloverthefinaloutputpresentation.
developerWorksibm.
com/developerWorks/SimulateXQueryandXIncludefunctionalitywithPHPPage2of8Example:Garden-centercooperationImaginethatatownhasthreegardencenters.
Theycompetewithoneanotherbutprovidesufficientlydifferentservicesthattheycandosocooperativelyratherthanantagonistically.
Theydosomemarketresearchtogetfindouthowtheircustomersbuytheirplants.
Inthehorticulturebusiness,salesofhighlyperishableproductsoccurinhighvolumeinashortperiodoftime,andcustomerscanbequiteparticularaboutthetypeandqualityofproductstheywant.
Itisinthebestinterestofthebusinesstogetthehigh-maintenanceproducts(forexample,thosethatneedtobewateredandkeptfreeofpests)outthedoorassoonaspossibleandtokeepamercurialcustomerbasehappybyprovidingthemwiththerightproductsattherighttimeandintherightplace.
Otherwisecustomersflocktothecompetitionthatcan.
Researchshowsthatcustomersdonotlikephoningaroundtofindwheretheycangettheirplants,andthehighvolumeofcallsisinconvenienttothebusinessesaswell.
Atthebeginningoftheseason,allthebusinesseshaveplentyofproduct.
Laterintheseason,despitegoodplanning,productstartstorunoutunevenly.
Customerslookingforpetuniasmighthavetophoneorvisitallthreegardencentersbeforetheyfindthehotpinkcolorthey'relookingfor.
Ingeneral,customerswanttoknowwhohaswhichplant,inwhatsizepot,inwhatquantity,andatwhatprice.
TheproposedsetupThethreeITmanagersholdameeting.
Theydecidetocreateacommonwebsitewherecustomerscanfindoutwhichgardencenterhasspecificplantsinstock.
Althoughallthreegardencentersarecomputerized,eachusesadifferentsystemtostoreinformation.
ApplesandThingsusesaMicrosoftAccessdatabasesystem,BirchTreesUnlimitedusesaLinuxsystemwithMySQL,andCarnationTarnationusesMacOSXwithIBMDB2.
Broadly,theydecidetoworktowardanXML-basedarchitecture.
XMLisaconvenientdataformatbecauseeachoftheirsystemscanexportcurrentdatatoanXMLfilethatisavailableinthecloud.
AmasterXMLfilecollectstheindividualstores'dataintoonecentralplace,usingXInclude.
Finally,themainwebpageexaminesthemasterfile,extractsthedatausingXQuery,andrendersthefinaldisplay.
ProcessingtheXMLwithXIncludeandXQueryTheITmanagersdecidethateachstorewillproduceanXMLfilesimilartotheoneinListing1:Listing1.
StoreXMLfile.
.
.
.
.
.
.
.
.
ibm.
com/developerWorks/developerWorksSimulateXQueryandXIncludefunctionalitywithPHPPage3of8PetuniaPink,in4inchpots1003.
00Appletree'Spartan'625.
00.
.
.
Thisfilehasastorerootelementandtwochildelements.
Theinfochildelementcontainsinformationaboutthestoreingeneral.
Theplantschildelementcontainsmanyplantchildelements,eachofwhichcontainsfurtherinformationaboutthatplant,includingthename,description,quantityandprice.
Allthreestoresfollowthispatternexactly.
Listing2istheirversionofamainXMLfilethatcombinesallthreestorefilessotheyappeartobeonelargefile,maintainingdetailsabouttheproducts:Listing2.
MainXMLfileInListing2,XIncludeisusedtofetchdatafromthethreelocationsusingHTTPinthecloud.
Afterprocessing,itlookslikeListing3:Listing3.
MainXMLfileexpandedApples.
.
.
.
.
.
Birches.
.
.
.
.
.
.
.
.
developerWorksibm.
com/developerWorks/SimulateXQueryandXIncludefunctionalitywithPHPPage4of8InListing3,theincludeinstructionsfromListing2arereplacedbythecontentsoftheindividualstoreXMLfiles.
EachstoreelementisnowachildelementoftheglobalstoreDataelement.
YoucannowapplyXQuerytothecombineddataset,asinListing4:Listing4.
ApplyingXQuery{for$storeindoc("mainXMLfile.
xml")/storeData/storelet$plants:=$store/plants/plantreturn{for$plantin$plantsorderby$plant/namereturn{concat($plant/quantity,"of",$plant/name,"at",$store/info/name,"for",$plant/price,"each")}

Nocser:马来西亚独立服务器促销$60.00/月

Nocser刚刚在WHT发布了几款促销服务器,Intel Xeon X3430,8GB内存,1TB HDD,30M不限流量,月付$60.00。Nocser是一家注册于马来西亚的主机商,主要经营虚拟主机、VPS和马来西亚独立服务器业务,数据中心位于马来西亚AIMS机房,线路方面,AIMS到国内电信一般,绕日本NTT;联通和移动比较友好,联通走新加坡,移动走香港,延迟都在100左右。促销马来西亚服务器...

CloudCone:$17.99/年KVM-1GB/50GB/1TB/洛杉矶MC机房

CloudCone在月初发了个邮件,表示上新了一个系列VPS主机,采用SSD缓存磁盘,支持下单购买额外的CPU、内存和硬盘资源,最低年付17.99美元起。CloudCone成立于2017年,提供VPS和独立服务器租用,深耕洛杉矶MC机房,最初提供按小时计费随时退回,给自己弄回一大堆中国不能访问的IP,现在已经取消了随时删除了,不过他的VPS主机价格不贵,支持购买额外IP,还支持购买高防IP。下面列...

RAKsmart含站群服务器/10G带宽不限流量首月半价

RAKsmart 商家估摸着前段时间服务器囤货较多,这两个月的促销活动好像有点针对独立服务器。前面才整理到七月份的服务器活动在有一些配置上比上个月折扣力度是大很多,而且今天看到再来部分的服务器首月半价,一般这样的促销有可能是商家库存充裕。比如近期有一些服务商挖矿服务器销售不好,也都会采用这些策略,就好比电脑硬件最近也有下降。不管如何,我们选择服务器或者VPS主机要本着符合自己需求,如果业务不需要,...

file_get_contents为你推荐
University163图书馆学、情报学期刊投稿指南iphone连不上wifi苹果手机为什么突然连不上家里的wifi?iexplore.exe应用程序错误iexplore.exe应用程序错误itunes备份怎么使用iTunes备份x-routerx-arcsinx的等价无穷小是什么?xp系统关闭445端口xp中,如何关闭掉一些没有用的端口,请高手解答?谷歌sb在谷歌里搜SB为什么结果中第一个是百度www.baidu.jpbaidu 百度www.baidu.jp谁能推荐几个日本的资源网站、搜索引擎、音乐软件?
火山主机 sharktech adman 狗爹 web服务器架设软件 南昌服务器托管 坐公交投2700元 我爱水煮鱼 老左来了 183是联通还是移动 t云 in域名 1元域名 服务器论坛 1美元 深圳主机托管 美国vpn代理 zencart安装 ubuntu安装教程 更多