PHP DOMDocument getElementsByTagName返回不完整的元素?

时间:2015-12-25 03:11:43

标签: php domdocument getelementsbytagname

我正在使用PHP 5.3。我有以下代码:

view1.html

while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: /var/folders/h9/zf2xtlkd12z1_ygkj8hplkhh17xrbq/C/org.llvm.clang.dzhuowen/ModuleCache/1VMMO06OSVUBF/Foundation-3DFYNEBRQSXST.pcm: No such file or directory
while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: /var/folders/h9/zf2xtlkd12z1_ygkj8hplkhh17xrbq/C/org.llvm.clang.dzhuowen/ModuleCache/1VMMO06OSVUBF/Foundation-3DFYNEBRQSXST.pcm: No object file for requested architecture
while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: /var/folders/h9/zf2xtlkd12z1_ygkj8hplkhh17xrbq/C/org.llvm.clang.dzhuowen/ModuleCache/1VMMO06OSVUBF/UIKit-1V5UHAPTOD24G.pcm: No such file or directory
while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: /var/folders/h9/zf2xtlkd12z1_ygkj8hplkhh17xrbq/C/org.llvm.clang.dzhuowen/ModuleCache/1VMMO06OSVUBF/UIKit-1V5UHAPTOD24G.pcm: No object file for requested architecture
while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: /var/folders/h9/zf2xtlkd12z1_ygkj8hplkhh17xrbq/C/org.llvm.clang.dzhuowen/ModuleCache/1VMMO06OSVUBF/Darwin-38I6DLZ5IH61J.pcm: No such file or directory 
while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: Could not resolve external type c:objc(cs)NSCache
while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: Could not resolve external type c:objc(cs)NSMapTable
while processing /Users/Yan/Documents/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork(FBCache.o):
warning: Could not resolve external type c:objc(cs)NSObject

的index.php

<!DOCTYPE html>
<html>
<head>
</head>
<body>
      <form method="post">
         <span>Hello this is some text</span>
         <input type="text" name="input1" value="mystuf"/>
         <p>Blah blah this is boring</p>
         <input type="text" name="input2" value="hello"/>
         <img src="image-of-a-kangaroo.png" />
         <input type="text" name="input3" />
         <ul>
            <li>Buy brocolli</li>
            <li>Buy oregano</li>
            <li>Buy milk</li>
         </ul>
         <input type="text" name="input4" />
         <textarea name="input100"></textarea>
         <input type="text" name="input101" />
         <p><strong>Yes, I like pizza!</strong><span>But my porcupine gets sick eating pizza.</span></p>
      </form>
</body>
</html>

为什么<?php $xmlDoc = new DOMDocument(); $xmlDoc->loadHTMLFile('view1.html'); $input = $xmlDoc->getElementsByTagName('input'); foreach ($input as $i) { echo $i->nodeValue, PHP_EOL; } 总是给出空的或没有结果?

1 个答案:

答案 0 :(得分:1)

做一个回声$i->getAttribute('value')向我展示了我正在寻找的价值观。