如何阅读< abc:xyz> XML标记使用PHP? [英] How read < abc: xyz > xml tag using php?

查看:133
本文介绍了如何阅读< abc:xyz> XML标记使用PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用下面的代码,我可以轻松读取<abcxyz> xml标签.但是我如何读取<abc:xyz> </abc:xml> xml标记之间的数据. xml标签使用php.pls帮助....

Using my below code i can read <abcxyz> xml tag easily. but how can i read the data between <abc:xyz> </abc:xml> xml tag.. xml tag using php.pls help....

我的php示例代码...

my php sample code...

 $objDOM->load("abc.xml"); 
  $note = $objDOM->getElementsByTagName("note");  
   foreach( $note as $value )
   {
    $tasks = $value->getElementsByTagName("tasks");
    $task  = $tasks->item(0)->nodeValue;
    $details = $value->getElementsByTagName("details");
    $detail  = $details->item(0)->nodeValue;    
    echo "$task :: $detail<br>";
   }

我的XML示例代码:

<mynotes>
     <note>
        <tasks>Task 1</tasks>
        <details>Detail 1</details>
     </note>
     <abc:xyz> Cannot Read the XML data between this tag</abc:xyz>
 </mynotes>

请引导我...

Pls guide me...

谢谢
里亚德

Thanks
Riad

推荐答案

abc:xyz表示该元素名为xyz,而命名空间abc表示.名称空间部分实际上是URI的简写,通常也在XML文件中给出.例如,您可能会看到以下内容:

abc:xyz means that the element is named xyz, and the namespace is indicated by abc. The namespace part is actually shorthand for an URI, which is usually also given in the XML file. For example, you may see this:

xmlns:abc="http://www.abc.com/xml"

在这种情况下,冒号前面有abc的元素位于名称空间http://www.abc.com/xml中.

In this case, elements which have abc before the colon are in the namespace http://www.abc.com/xml.

要检索此元素,您需要使用 getElementsByTagNameNS 并通过http://www.abc.com/xml作为名称空间.

To retrieve this element, you need to use getElementsByTagNameNS and pass http://www.abc.com/xml as the namespace.

这篇关于如何阅读&lt; abc:xyz&gt; XML标记使用PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆