xml 提取属性

前端之家收集整理的这篇文章主要介绍了xml 提取属性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<root>

<applist>

<appInfo app_name="扎金花"
package_name="com.zjh.cmge"
version_name="2.3"
version_code="1"
block_fr=""
size="11.50M"
icon_url="http://download.haoma.sogou.com/Android/recommend/images/cmgegame.png?f=sogouhaomatong"
download_url="http://download.haoma.sogou.com/Android/recommend/apk/cmgegame_zjh_v2.3_16651.apk?f=sogouhaomatong" brief_desc="最专业最富人气的炸金花">
</appInfo>
<appInfo app_name="找你妹"
package_name="org.funship.findsomething.withRK"
version_name="4.0.0"
version_code="1"
block_fr=""
size="64.42M"
icon_url="http://download.haoma.sogou.com/Android/recommend/images/FindSomething.png?f=sogouhaomatong"
download_url="http://download.haoma.sogou.com/Android/recommend/apk/FindSomething.apk?f=sogouhaomatong" brief_desc="传统找茬与角色扮演的经典结合">
</appInfo>
</applist>
</root>


$string = file_get_contents("appInfo.xml");

$xml = simplexml_load_string($string); $xml = $xml->applist; //print_r($xml);exit; foreach($xml->appInfo as $node) { $name = $node->attributes()->app_name ; $icon_url = $node->attributes()->icon_url ; $download_url = $node->attributes()->download_url ; file_put_contents("app.txt",trim($name) . " " . trim($icon_url) . " " . trim($download_url) . PHP_EOL,FILE_APPEND) ; } 原文链接:https://www.f2er.com/xml/299921.html

猜你在找的XML相关文章