当前位置:网站首页>PHP read XML file
PHP read XML file
2022-07-18 19:18:00 【Dream Island】
List of articles
One 、 Reference link
PHP SimpleXML function -W3school
PHP XML SimpleXML | Novice tutorial
Two 、 Example


Two 、 Code
mysql.xmlfile
<?xml version="1.0"?>
<mysql>
<!-- Database name -->
<database>foxtown</database>
<!-- Database user name -->
<username>root</username>
<!-- Database password -->
<passwd>toor</passwd>
</mysql>
test1.phpfile
<?php
$xml_object = simplexml_load_file("mysql.xml");// Import xml
$xml_json = json_encode($xml_object);// Convert to json data
$xml_array = json_decode($xml_json,true);// Convert to array
print_r($xml_array);
echo "<br>";
echo $xml_array["username"];// full name
echo "<br>";
echo $xml_array["passwd"];// password
?>
边栏推荐
猜你喜欢
随机推荐
《构建H3C高性能园区网络》
2021年11月软考网络规划设计师上午真题及答案解析
Arbre DS - AVL de haut niveau
IO exception handling
Win11如何解除网络限速?Win11解除网络限速的方法
Summary of real papers of senior network planning designer for soft test over the years 2009-2021
Splunk 配置多集群 index
SFF1602-MHCHXM超快恢复二极管SFF1602
Key technologies and solutions of virtualization
我读《时间的观念》
基於Web的爬蟲系統設計與實現
电子协会 C语言 2级 20 、 合法 C 标识符
PHP-for标签end属性的动态传参问题(Thinkphp)
自定义jsp标签
World Internet Conference
Codeforces Round #807 (Div. 2)ABC
Code forces round # 807 (DIV. 2) a - - D
dataworks同步数据到兼容mysql协议中间件 ,速度很慢,加了带宽也无明显提速,怎么办?
Custom JSP tag
One question per day on July 13, 2020 (structure)









