使用我的下面的代码我可以<abcxyz>轻松读取xml标签.但我如何<abc:xyz> </abc:xml>使用php.pls帮助读取xml标签.. xml标签之间的数据....
我的php示例代码...
$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>";
}
Run Code Online (Sandbox Code Playgroud)
我的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>
Run Code Online (Sandbox Code Playgroud)
请指导我......
由于
里亚德
abc:xyz表示该元素已命名xyz,并且该命名空间由表示abc.命名空间部分实际上是URI的简写,通常也在XML文件中给出.例如,您可能会看到:
xmlns:abc="http://www.abc.com/xml"
在这种情况下,abc冒号前面的元素位于命名空间中http://www.abc.com/xml.
要检索此元素,您需要使用getElementsByTagNameNS并将其http://www.abc.com/xml作为命名空间传递.
| 归档时间: |
|
| 查看次数: |
3264 次 |
| 最近记录: |