2012-02-02 7 views
1

このようなエラーが表示される理由を教えてください。最初はホワイトスペースのためにそれを考えましたが、ホワイトスペースで作業した後です。私はあなたの問題を探し、それはまだ私にこのエラーが発生します:(警告:DOMDocument :: loadXML()[domdocument.loadxml]:データの早すぎる末尾

ここに私のXMLコードだ

<?xml version="1.0" ?> 
<produk> 
    <softSpec> 
     <style>android iphone</style> 
     <comm> 
      <simSvas>1</simSvas> 
      <dataScon> 
       <gprs>1</gprs> 
       <wap>1</wap> 
      </dataScon> 
      <message> 
       <sms> 
        <swr>1</swr> 
        <sin>1</sin> 
        <sout>1</sout> 
        <sdrf>1</sdrf> 
        <ssent>1</ssent> 
       </sms> 
       <mms> 
        <mwr>1</mwr> 
        <min>1</min> 
        <mout>1</mout> 
        <mdrf>1</mdrf> 
        <msent>1</msent> 
        <groupSmms>1</groupSmms> 
        <mmsSchatSroom>1</mmsSchatSroom> 
        <commSbm>1</commSbm> 
       </mms> 
       <email> 
        <esent>0</esent> 
        <erecv>0</erecv> 
        <ein>0</ein> 
        <eout>0</eout> 
        <esent>0</esent> 
        <edrft>0</edrft> 
        <eact>0</eact> 
       </email> 
      </message> 
      <phonebook> 
       <capacity>500</capacity> 
       <searchCon>1</searchCon> 
       <add>1</add> 
       <save>1</save> 
       <dial>1</dial> 
       <grupNum>1</grupNum> 
       <captiveChk>1</captiveChk> 
      </phonebook> 
      <call> 
       <simShist> 
        <sim1>1</sim1> 
        <sim2>1</sim2> 
       </simShist> 
       <dialSupSip>1</dialSupSip> 
       <callSgrup>0</callSgrup> 
       <setScallSid>0</setScallSid> 
       <callSdiv>1</callSdiv> 
       <callSbar>1</callSbar> 
       <callShold>1</callShold> 
       <callSredial>1</callSredial> 
       <callSfee>1</callSfee> 
       <handsfree>1</handsfree> 
       <cdial>1</cdial> 
       <crecv>1</crecv> 
       <callSrec></callSrec> 
      </call> 
     </comm> 
     <multimedia> 
      <cam> 
       <swScam>1</swScam> 
       <subScam>1</subScam> 
       <mainScam>1</mainScam> 
       <capt>1</capt> 
       <zoom>1</zoom> 
       <contras>1</contras> 
       <save>1</save> 
       <flash>0</flash> 
       <setStoSwpp>1</setStoSwpp> 
       <viewSpic>1</viewSpic> 
       <wbSconf>1</wbSconf> 
       <contSphoto>1</contSphoto> 
       <exposureScomp>1</exposureScomp> 
       <effectSset>1</effectSset> 
      </cam> 
      <video> 
       <vidSform> 
        <mp4>1</mp4> 
        <trigp>1</trigp> 
        <avi>1</avi> 
        <rmvb>1</rmvb> 
        <kingSmov>1</kingSmov> 
       </vidSform> 
       <vidSrec>1</vidSrec> 
       <swScam>1</swScam> 
       <vidSfcam>0</vidSfcam> 
       <vidSrcam>1</vidSrcam> 
       <vidSzoom>1</vidSzoom> 
       <contras>1</contras> 
       <save> 
        <phone>1</phone> 
        <mmc>1</mmc> 
       </save> 
       <vidSplay>1</vidSplay> 
       <vidSdisp>1</vidSdisp> 
       <adjSvol>1</adjSvol> 
       <addSvid> 
        <fromScard>1</fromScard> 
        <fromSphone>1</fromSphone> 
       </addSvid> 
       <vidSapp>1</vidSapp> 
      </video> 
      <audio> 
       <audSform> 
        <mp3>1</mp3> 
        <wav>1</wav> 
        <midi>1</midi> 
       </audSform> 
       <play>1</play> 
       <playlist>1</playlist> 
       <playSsett>1</playSsett> 
       <backSsound>1</backSsound> 
       <btoothSaudSout>0</btoothSaudSout> 
       <adjSvol>1</adjSvol> 
       <add> 
         <fromScard>1</fromScard> 
         <fromSphone>1</fromSphone> 
        </add> 
       <radio>1</radio> 
       <radioSmenu> 
        <radSplay>1</radSplay> 
        <adjSvol>1</adjSvol> 
        <selectSfeq>1</selectSfeq> 
        <saveSfreq>0</saveSfreq> 
        <searchSfreq>1</searchSfreq> 
        <record>0</record> 
        <save> 
         <card>0</card> 
         <phone>0</phone> 
        </save> 
       </radioSmenu> 
       <soundSrec>1</soundSrec> 
       <soundSrecSmenu> 
        <record>1</record> 
        <play>1</play> 
        <save> 
         <card>1</card> 
         <phone>1</phone> 
        </save> 
       </soundSrecSmenu>     
      </audio> 
      <imaging> 
       <imSviewer>1</imSviewer> 
       <imSviewerSmenu> 
        <rotate>1</rotate> 
        <zoom>1</zoom> 
        <slide>1</slide> 
        <setSwpp>1</setSwpp> 
        <send> 
         <viaSbtooth>1</viaSbtooth> 
         <viaSmms>1</viaSmms> 
        </send> 
        <edit>1</edit> 
        <detail>1</detail> 
       </imSviewerSmenu> 
       <photoEditor>1</photoEditor> 
       <photoSeditorSmenu> 
        <autoSresize>0</autoSresize> 
       </photoSeditorSmenu> 
      </imaging> 
      <anotherSmfunc> 
       <tv>1</tv> 
       <games>1</games> 
       <gps>0</gps> 
       <keypadSlock>1</keypadSlock> 
      </anotherSmfunc> 
     </multimedia> 
     <service> 
      <simSserv> 
       <stkSsimS1>1</stkSsimS1> 
       <stkSsimS2>1</stkSsimS2> 
       <browsing>1</browsing> 
      </simSserv> 
      <chat>1</chat> 
      <java>0</java> 
      <opera>0</opera> 
      <mSoffc>0</mSoffc> 
      <fbSsc>0</fbSsc> 
      <pimoSsc>0</pimoSsc> 
      <tpulsaSsc>0</tpulsaSsc> 
     </service> 
     <tools> 
      <btooth> 
       <onSoff>1</onSoff> 
       <send>1</send> 
       <recv>1</recv> 
       <a2dp>0</a2dp> 
      </btooth> 
      <cald>1</cald> 
      <calc>1</calc> 
      <task>0</task> 
      <alarm>1</alarm> 
      <wSclock>1</wSclock> 
      <uSconvrt>1</uSconvrt> 
      <currSconv>1</currSconv> 
      <healthSman>1</healthSman> 
      <ebookSread>1</ebookSread> 
      <swatch>0</swatch> 
      <notes>1</notes> 
      <codeStable>1</codeStable> 
      <updownloadSpbook>0</updownloadSpbook> 
      <usrSprof>1</usrSprof> 
      <handwritting>1</handwritting> 
     </tools> 
     <sett> 
      <fileSman> 
       <intSmem>1</intSmem> 
       <extSmem>1</extSmem> 
       <rwmrmov>1</rwmrmov> 
       <format>1</format> 
      </fileSman> 
      <disp> 
       <wpp>1</wpp> 
       <ssaver>1</ssaver> 
       <ponSdisp>1</ponSdisp> 
       <poffSdisp>1</poffSdisp> 
       <showSownSnum>0</showSownSnum> 
      </disp> 
      <pSsett> 
       <schSpowSon>1</schSpowSon> 
       <inSlang> 
        <eng>1</eng> 
        <stroke>1</stroke> 
        <piyin>1</piyin> 
        <french>0</french> 
        <german>0</german> 
        <spain>0</spain> 
        <russian>0</russian> 
        <indonesian>1</indonesian> 
        <portugis>0</portugis> 
        <turkish>0</turkish> 
        <persian>0</persian> 
        <italia>0</italia> 
       </inSlang> 
       <lang> 
        <eng>1</eng> 
        <ind>0</ind> 
        <china>1</china> 
        <french>0</french> 
        <german>0</german> 
        <spain>0</spain> 
        <russian>0</russian> 
        <indonesian>0</indonesian> 
        <portugis>0</portugis> 
        <turkish>0</turkish> 
        <persian>0</persian> 
        <italia>0</italia> 
       </lang> 
       <timeSdate>1</timeSdate> 
       <prefSin>0</prefSin> 
       <greetStext>0</greetStext> 
       <dedicSkey>0</dedicSkey> 
       <autoSupdateStime>1</autoSupdateStime> 
       <uartSsett>0</uartSsett>     
      </pSsett> 
      <sSoth> 
       <soundSsett>1</soundSsett> 
       <soundSsettSopt> 
        <audSeff>1</audSeff> 
        <bassSench>0</bassSench> 
       </soundSsettSopt> 
       <dualSsimSsw>0</dualSsimSsw> 
       <dualSsimSsett>0</dualSsimSsett> 
       <penScall>0</penScall> 
       <netwSsett>0</netwSsett> 
       <secSsett>0</secSsett> 
       <restSsett>0</restSsett> 
      </sSoth> 
      <miscSsett> 
       <sensSapp> 
        <wallSshuff>0</wallSshuff> 
        <mp3Sshuff>0</mp3Sshuff> 
        <phoneSshake>0</phoneSshake> 
        <shakeStoSreadSsms>0</shakeStoSreadSsms> 
        <fmSchsSshake>0</fmSchsSshake> 
        <revrseSphoneSmute>0</revrseSphoneSmute> 
        <doubleSknockSmute>0</doubleSknockSmute> 
       </sensSapp> 
       <voiceaidSsett> 
        <enginSsett>0</enginSsett> 
        <rSinScall>0</rSinScall> 
        <rSinSmess>0</rSinSmess> 
        <rStimeSonSidle>0</rStimeSonSidle> 
        <rStimeSperShour>0</rStimeSperShour> 
        <rSmenu>0</rSmenu> 
        <rSmesg>0</rSmesg> 
        <rScharge>0</rScharge> 
        <rSdial>0</rSdial> 
        <vol>0</vol> 
        <rate>0</rate> 
        <pith>0</pith> 
       </voiceaidSsett> 
       <wapp> 
        <wappSform> 
         <gif>1</gif> 
         <bmp>1</bmp> 
         <jpg>1</jpg> 
        </wappSform> 
        <wallScust>1</wallScust> 
        <dynamicSscreensaver>0</dynamicSscreensaver> 
       </wapp> 
      </miscSsett> 
     </sett>  
     <miscSfunc> 
      <ani> 
       <pSonSlogo>1</pSonSlogo> 
       <pSoffSlogo>1</pSoffSlogo> 
      </ani> 
      <ring> 
       <default>1</default> 
       <ringSform> 
        <mp3>1</mp3> 
        <midi>1</midi> 
        <wav>1</wav> 
       </ringSform> 
       <backSringSforScall>1</backSringSforScall> 
       <ringSedit>1</ringSedit> 
      </ring> 
      <vibSfeedback> 
       <touchSscr>1</touchSscr> 
       <dialSnum>1</dialSnum> 
      </vibSfeedback> 
     </miscSfunc> 
    </softSpec> 

</produk> 

、ここでは私のPHPコードが

<?php 
//buat matching database 
$existdb="http://localhost:8080/exist/testing"; 

function URLopen($url){ 
    $dh = fopen("$url",'r'); 
    $result= fread($dh,8192); //fread buat baca filenyeah 
    return $result; 
} 

$codeparameter = $existdb.'/retrieve_codetable.xql'; 
$returnedpcode=URLopen($codeparameter); 
$fileparameter = $existdb.'/coba.xql'; 
$returnedpfile=URLopen($fileparameter); 
//echo $returnedpfile; 

$dom=new DOMDocument; 
$dom->loadXML($returnedpcode); 
$dom1=new DOMDocument; 
$dom1->loadXML($returnedpfile); 


$xpath = new DOMXpath($dom1); 
$query = '/produk//*'; 
$entries=$xpath->query($query); 

foreach($entries as $entry){ 
    echo "[" . $entry->nodeName."]"; 
} 


?> 
+0

あなたはXML文書を1つだけ表示していますが、PHPコードは2つを参照しています。 –

+0

はいはい..しかし、他のファイルは正常に動作しています。それは有効になりません:) – user1183172

+0

Hmm strange ... complexType要素を閉じないとここに来ますが、ここでコピーしたXMLは有効です。 (おそらくあなたはその中にユニコードの空白文字を持っているかもしれません) – inf3rno

答えて

0

だOK。データの早すぎる終わりのようですfread()関数の結果

URLopen()関数を少し書き直してみてください。

function URLopen($url) 
{ 
    $dh = fopen($url,'r'); 
    $result = ''; 
    while (!feof($dh)) 
    { 
     $result .= fread($dh, 8192); // Put this in a while loop. 
    } 
    return $result; 
} 

スクリプトでは、最大8kbのファイルのみが読み込まれます。たぶんあなたのXMLファイルの1つが大きかったかもしれません。

関連する問題