dom002.phpt
来自「PHP v6.0 For Linux 运行环境:Win9X/ WinME/ Wi」· PHPT 代码 · 共 83 行
PHPT
83 行
--TEST--Test 2: getElementsByTagName() / getElementsByTagNameNS()--SKIPIF--<?php require_once('skipif.inc'); ?>--FILE--<?php$xml = b<<<HERE<?xml version="1.0" encoding="ISO-8859-1" ?><foo xmlns="http://www.example.com/ns/foo" xmlns:fubar="http://www.example.com/ns/fubar"> <bar><test1 /></bar> <bar><test2 /></bar> <fubar:bar><test3 /></fubar:bar> <fubar:bar><test4 /></fubar:bar></foo>HERE;function dump($elems) { foreach ($elems as $elem) { var_dump($elem->nodeName); dump($elem->childNodes); }}$dom = new DOMDocument();$dom->loadXML($xml);$doc = $dom->documentElement;dump($dom->getElementsByTagName('bar'));dump($doc->getElementsByTagName('bar'));dump($dom->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar'));dump($doc->getElementsByTagNameNS('http://www.example.com/ns/fubar', 'bar'));?>--EXPECT--string(3) "bar"string(5) "test1"string(3) "bar"string(5) "test2"string(9) "fubar:bar"string(5) "test3"string(9) "fubar:bar"string(5) "test4"string(3) "bar"string(5) "test1"string(3) "bar"string(5) "test2"string(9) "fubar:bar"string(5) "test3"string(9) "fubar:bar"string(5) "test4"string(9) "fubar:bar"string(5) "test3"string(9) "fubar:bar"string(5) "test4"string(9) "fubar:bar"string(5) "test3"string(9) "fubar:bar"string(5) "test4"--UEXPECT--unicode(3) "bar"unicode(5) "test1"unicode(3) "bar"unicode(5) "test2"unicode(9) "fubar:bar"unicode(5) "test3"unicode(9) "fubar:bar"unicode(5) "test4"unicode(3) "bar"unicode(5) "test1"unicode(3) "bar"unicode(5) "test2"unicode(9) "fubar:bar"unicode(5) "test3"unicode(9) "fubar:bar"unicode(5) "test4"unicode(9) "fubar:bar"unicode(5) "test3"unicode(9) "fubar:bar"unicode(5) "test4"unicode(9) "fubar:bar"unicode(5) "test3"unicode(9) "fubar:bar"unicode(5) "test4"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?