Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php解析xml属性_Php_Xml_Xml Parsing - Fatal编程技术网

php解析xml属性

php解析xml属性,php,xml,xml-parsing,Php,Xml,Xml Parsing,我知道关于使用php从xml文件中读取属性的答案和示例不胜枚举。但在尝试实现这一点之后,我没有成功,因此我提出了这个问题 我有一个结构如下的xml文件: <warning warning_type="warned"> <sentdate>20110823</sentdate> <senttime>2154</senttime> </warning> 如果节点位于XML文件的根级别,则只需执行以下操作: $xml

我知道关于使用php从xml文件中读取属性的答案和示例不胜枚举。但在尝试实现这一点之后,我没有成功,因此我提出了这个问题

我有一个结构如下的xml文件:

<warning warning_type="warned">
   <sentdate>20110823</sentdate>
   <senttime>2154</senttime>
</warning>
如果
节点位于XML文件的根级别,则只需执行以下操作:

$xml=simplexml_load_file('http://myserver.com/ews/VVKRGN_xml');
$warning_type = $xml['warning_type'];
是XML文件中的第一个节点吗?XML文件需要有一个根节点,然后在它下面有子节点。
$xml=simplexml_load_file('http://myserver.com/ews/VVKRGN_xml');
$warning_type = $xml['warning_type'];