php
  • html
  • simplexml
  • 2013-10-30 72 views 0 likes 
    0

    因此,繼承人我的問題!我在我的網站中使用simplexml作爲MySQL的替代品,因爲我使用移動設備,它的addChild請求工作正常,但是當它提交時它覆蓋原始的xml文件或者我用代碼xml文件解釋它:PHP SimpleXML錯誤更新xml文件

    <?xml version="1.0"?> 
    <video><title>title 22</title></video> 
    

    php文件:

    <?php 
    $file = 'database.xml'; 
    $title = $_POST['1']; 
    $xml = simplexml_load_file($file); 
    $xmlne = $xml->videos; 
    $d = "<video></video>"; 
    $newvid = new SimpleXMLElement($d); 
    $newvid->addChild('title' , $title); 
    $newvid->asXML($file); 
    ?> 
    <form action="index.php" method="post"> 
    <input type="text" value="title" name="1"> 
    <input type="submit" value="post"/> 
    </form> 
    
    +0

    說,如果我把標題23到形式,它覆蓋到23 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/2936438/">user2936438</a></span> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">_「我用代碼xml文件解釋它」_:最好用單詞解釋它,然後_then_顯示重現它的代碼。我真的不明白_「它會覆蓋原始的xml」,並且我不想在我的大腦中執行它,只是爲了理解這個問題! – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/2718747/">geomagas</a></span> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">數據保存,但我希望它增加,所以它添加一個新的元素下其他 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/2936438/">user2936438</a></span> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="answer-title"> <span class="text-logo margin-top-sm">A</span> <h2 class="title h4">回答</h2> </div> <div class="item-description text-md markdown-body margin-bottom-40 voidso"> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">2<i class="fa fa-thumbs-up"></i></span> </div> <div class="post-offset"> <div class="answer fmt"> <p>你的問題是,這一行創建了一個新的XML文檔,從原始文件完全獨立:</p> <pre><code class="prettyprint-override">$newvid = new SimpleXMLElement($d); </code></pre> <p>呦然後在你的新文檔中添加一個元素,並保存到原始文件名,丟失原始文件。</p> <p>你真正想要做的就是添加一個新的視頻元素,你加載<code class="prettyprint-override">$xml</code>,然後將現有文檔什麼遍歷找到<code class="prettyprint-override">$xmlne</code>:</p> <pre><code class="prettyprint-override">$newvid = $xmlne->addChild('video'); </code></pre> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/19686701">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2013-10-30 15:16:30</span> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/157957/">IMSoP</a></span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> </div> </article> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1038284119" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">相關問題</div> <ul class="relative_list"> <li> 1. <a href="http://hk.uwenku.com/question/p-cpswypfe-qq.html" target="_blank" title="用php simplexml工具更新xml文件"> 用php simplexml工具更新xml文件 </a> </li> <li> 2. <a href="http://hk.uwenku.com/question/p-hkyxjgbi-zg.html" target="_blank" title="PHP SimpleXML錯誤"> PHP SimpleXML錯誤 </a> </li> <li> 3. <a href="http://hk.uwenku.com/question/p-vvhxdzjg-c.html" target="_blank" title="如何在PHP中使用Simplexml分析錯誤的XML文件?"> 如何在PHP中使用Simplexml分析錯誤的XML文件? </a> </li> <li> 4. <a href="http://hk.uwenku.com/question/p-ujaxmwsa-nn.html" target="_blank" title="PHP錯誤解析XML(SimpleXML的)"> PHP錯誤解析XML(SimpleXML的) </a> </li> <li> 5. <a href="http://hk.uwenku.com/question/p-zzmaeqeu-x.html" target="_blank" title="Cron PHP simplexml錯誤"> Cron PHP simplexml錯誤 </a> </li> <li> 6. <a href="http://hk.uwenku.com/question/p-fsdiwcdo-ban.html" target="_blank" title="用simplexml加載XML文件"> 用simplexml加載XML文件 </a> </li> <li> 7. <a href="http://hk.uwenku.com/question/p-xehhsuoo-bka.html" target="_blank" title="PHP 7 simpleXML致命錯誤"> PHP 7 simpleXML致命錯誤 </a> </li> <li> 8. <a href="http://hk.uwenku.com/question/p-phqjxtqk-bda.html" target="_blank" title="PHP SimpleXML語法錯誤"> PHP SimpleXML語法錯誤 </a> </li> <li> 9. <a href="http://hk.uwenku.com/question/p-bzbccsmm-ux.html" target="_blank" title="SimpleXML的錯誤處理PHP"> SimpleXML的錯誤處理PHP </a> </li> <li> 10. <a href="http://hk.uwenku.com/question/p-kghrdobz-sc.html" target="_blank" title="PHP SimpleXML錯誤信息"> PHP SimpleXML錯誤信息 </a> </li> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6208739752673518" data-ad-slot="4606349252"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <li> 11. <a href="http://hk.uwenku.com/question/p-bfhrihvm-dx.html" target="_blank" title="simplexml的負載xml文件"> simplexml的負載xml文件 </a> </li> <li> 12. <a href="http://hk.uwenku.com/question/p-hlhkcdax-bz.html" target="_blank" title="PHP SimpleXML新行"> PHP SimpleXML新行 </a> </li> <li> 13. <a href="http://hk.uwenku.com/question/p-tjaswami-sq.html" target="_blank" title="SimpleXML addChild錯誤"> SimpleXML addChild錯誤 </a> </li> <li> 14. <a href="http://hk.uwenku.com/question/p-nytokoiv-wt.html" target="_blank" title="錯誤更新EDMX文件"> 錯誤更新EDMX文件 </a> </li> <li> 15. <a href="http://hk.uwenku.com/question/p-wkekdbju-bac.html" target="_blank" title="PHP的DOMDocument - 檢查更新XML文件"> PHP的DOMDocument - 檢查更新XML文件 </a> </li> <li> 16. <a href="http://hk.uwenku.com/question/p-xquvtwgb-nm.html" target="_blank" title="使用php Xpath更新xml文件"> 使用php Xpath更新xml文件 </a> </li> <li> 17. <a href="http://hk.uwenku.com/question/p-wogwdtoz-bhp.html" target="_blank" title="使用PHP腳本更新XML文件"> 使用PHP腳本更新XML文件 </a> </li> <li> 18. <a href="http://hk.uwenku.com/question/p-ojkmzsdr-vo.html" target="_blank" title="更新XML文件"> 更新XML文件 </a> </li> <li> 19. <a href="http://hk.uwenku.com/question/p-umvfkejl-yv.html" target="_blank" title="更新XML文件"> 更新XML文件 </a> </li> <li> 20. <a href="http://hk.uwenku.com/question/p-yrqscidv-bbg.html" target="_blank" title="PHP解析xml文件錯誤"> PHP解析xml文件錯誤 </a> </li> <li> 21. <a href="http://hk.uwenku.com/question/p-rvjznrgl-bdc.html" target="_blank" title="PHP的SimpleXML基於XML"> PHP的SimpleXML基於XML </a> </li> <li> 22. <a href="http://hk.uwenku.com/question/p-ncilqois-tc.html" target="_blank" title="用PHP解析XML - SimpleXML"> 用PHP解析XML - SimpleXML </a> </li> <li> 23. <a href="http://hk.uwenku.com/question/p-ojuldvvv-pv.html" target="_blank" title="xml使用php處理(simplexml?)"> xml使用php處理(simplexml?) </a> </li> <li> 24. <a href="http://hk.uwenku.com/question/p-aroskfpq-bba.html" target="_blank" title="用PHP的simpleXML解析XML"> 用PHP的simpleXML解析XML </a> </li> <li> 25. <a href="http://hk.uwenku.com/question/p-fkbsbmny-zb.html" target="_blank" title="使用PHP解析XML(simplexml)"> 使用PHP解析XML(simplexml) </a> </li> <li> 26. <a href="http://hk.uwenku.com/question/p-ppkstjle-xu.html" target="_blank" title="解析XML與PHP的SimpleXML"> 解析XML與PHP的SimpleXML </a> </li> <li> 27. <a href="http://hk.uwenku.com/question/p-kphxkqhb-bdp.html" target="_blank" title="simplexml中的XML創建(php)"> simplexml中的XML創建(php) </a> </li> <li> 28. <a href="http://hk.uwenku.com/question/p-tcgorgzk-boc.html" target="_blank" title="PHP:使用SimpleXML解析XML"> PHP:使用SimpleXML解析XML </a> </li> <li> 29. <a href="http://hk.uwenku.com/question/p-hggqouvu-vo.html" target="_blank" title="使用SimpleXML解析FCPx XML文件"> 使用SimpleXML解析FCPx XML文件 </a> </li> <li> 30. <a href="http://hk.uwenku.com/question/p-thhtdobf-vc.html" target="_blank" title="更新magento文件時更新XML"> 更新magento文件時更新XML </a> </li> </ul> </div> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1575177025"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img.uwenku.com/uwenku/script/side.js?t=1644592048261"></script> <script type="text/javascript" src="http://img.uwenku.com/uwenku/plugin/highlight/highlight.pack.js"></script> <link href="http://img.uwenku.com/uwenku/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="5415218910" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> 最新問題 </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-nektflpk-bbo.html" target="_blank" title="字體面在IE或邊緣"> 字體面在IE或邊緣 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-yrrswvsk-xg.html" target="_blank" title="訪問變量和模塊的方法,在多模塊程序"> 訪問變量和模塊的方法,在多模塊程序 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-cwqvptsm-yy.html" target="_blank" title="如何在C#中使用Web HDFS REST API追加文件?"> 如何在C#中使用Web HDFS REST API追加文件? </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-adtrrjqe-zp.html" target="_blank" title="Google Drive API v3 .NET:如何讓用戶直接從谷歌驅動器下載文件而不是從服務器下載文件?"> Google Drive API v3 .NET:如何讓用戶直接從谷歌驅動器下載文件而不是從服務器下載文件? </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-uzqoevxw-xw.html" target="_blank" title="行表中的Javafx表"> 行表中的Javafx表 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-tjaeqkvp-xp.html" target="_blank" title="最佳/最有效的方式爲nvarchar(最大)轉換到爲nvarchar(30)"> 最佳/最有效的方式爲nvarchar(最大)轉換到爲nvarchar(30) </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-xspueoga-ym.html" target="_blank" title="無法加入Mapbox SDK來的build.gradle"> 無法加入Mapbox SDK來的build.gradle </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-motyakjv-yc.html" target="_blank" title="Ramdajs keyBy相當於lodash"> Ramdajs keyBy相當於lodash </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-pkzicjfz-wn.html" target="_blank" title="PHP無法發送UTF-8的消息"> PHP無法發送UTF-8的消息 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-mpazrjuc-wd.html" target="_blank" title="從表構建樹結構?"> 從表構建樹結構? </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> 相關問題</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-cpswypfe-qq.html" target="_blank" title="用php simplexml工具更新xml文件"> 用php simplexml工具更新xml文件 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-hkyxjgbi-zg.html" target="_blank" title="PHP SimpleXML錯誤"> PHP SimpleXML錯誤 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-vvhxdzjg-c.html" target="_blank" title="如何在PHP中使用Simplexml分析錯誤的XML文件?"> 如何在PHP中使用Simplexml分析錯誤的XML文件? </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-ujaxmwsa-nn.html" target="_blank" title="PHP錯誤解析XML(SimpleXML的)"> PHP錯誤解析XML(SimpleXML的) </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-zzmaeqeu-x.html" target="_blank" title="Cron PHP simplexml錯誤"> Cron PHP simplexml錯誤 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-fsdiwcdo-ban.html" target="_blank" title="用simplexml加載XML文件"> 用simplexml加載XML文件 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-xehhsuoo-bka.html" target="_blank" title="PHP 7 simpleXML致命錯誤"> PHP 7 simpleXML致命錯誤 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-phqjxtqk-bda.html" target="_blank" title="PHP SimpleXML語法錯誤"> PHP SimpleXML語法錯誤 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-bzbccsmm-ux.html" target="_blank" title="SimpleXML的錯誤處理PHP"> SimpleXML的錯誤處理PHP </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-kghrdobz-sc.html" target="_blank" title="PHP SimpleXML錯誤信息"> PHP SimpleXML錯誤信息 </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hk.uwenku.com/contact">聯系我們</a></li> <li>© 2020 HK.UWENKU.COM</li> <li><a target="_blank" href="https://beian.miit.gov.cn/">沪ICP备13005482号-4</a></li> <li><script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280101193&web_id=1280101193"></script></li> <li><a href="http://www.uwenku.com/" target="_blank" title="优文库">简体中文</a></li> <li><a href="http://hk.uwenku.com/" target="_blank" title="優文庫">繁體中文</a></li> <li><a href="http://ru.uwenku.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.uwenku.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.uwenku.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.uwenku.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.uwenku.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.uwenku.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.uwenku.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.uwenku.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.uwenku.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.uwenku.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.uwenku.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f78a970f17b19a79fc477a3378096f29"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>