php修改和增加xml結點屬性

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   ar   for   sp   div   

<?xml version="1.0" encoding="UTF-8" ?><clientSet><server url="192.168.0.180" port="1935" /><rootPath value="" /><homePath value="http://www.aaa.com" /><helpPath value="help.html" /><language value="en" /><theme value="default" /><visibleMarquee value = "true" /><visibleWhitePaper value="true" /><showMemberRoomForGuest value = "true" /><emotions enabled="true" column="5" autoPlay="false"><item name="Birthday" src="cartoon/movie/birthday.swf" thumb="cartoon/preview/birthday-small.swf" duration="15"/><item name="Boom" src="cartoon/movie/boom.swf" thumb="cartoon/preview/boom-small.swf" duration="6"/><item name="Bubble" src="cartoon/movie/bubble.swf" thumb="cartoon/preview/bubble-small.swf" duration="7.5"/><item name="Cry" src="cartoon/movie/cry.swf" thumb="cartoon/preview/cry-small.swf" duration="5.4"/><item name="Doggie" src="cartoon/movie/doggie.swf" thumb="cartoon/preview/doggie-small.swf" duration="13"/><item name="Greeting" src="cartoon/movie/greeting.swf" thumb="cartoon/preview/greeting-small.swf" duration="7.4"/><item name="Football" src="cartoon/movie/football.swf" thumb="cartoon/preview/football-small.swf" duration="2.2"/></emotions ></clientSet> <?$dom=new DOMDocument(‘1.0‘);$dom->load(‘x.xml‘);$em=$dom->getElementsByTagName(‘emotions‘);$em=$em->item(0);$items=$em->getElementsByTagName(‘item‘);foreach($items as $a){foreach($a->attributes as $b){if($b->nodeValue==‘Birthday‘){$a->setAttribute(‘name‘,‘nBirthday‘);}}}$t=$dom->createElement(‘item‘);$t->setAttribute(‘name‘,‘x‘);$t->setAttribute(‘src‘,‘www.sohu.com‘);$t->setAttribute(‘duration‘,‘duration‘);$em->appendChild($t);$dom->save(‘x.xml‘);?>

 

php修改和增加xml結點屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.