开发者

XMLReader expand() issues -- produces Warning: DOM support is not enabled

开发者 https://www.devze.com 2022-12-26 19:12 出处:网络
I\'m new to XMLReader and novice at PHP.I\'m trying to figure out how to use XMLReader to parse XML files.In particular, I\'m trying to grab particular nodes of a very large XML file so that I can rew

I'm new to XMLReader and novice at PHP. I'm trying to figure out how to use XMLReader to parse XML files. In particular, I'm trying to grab particular nodes of a very large XML file so that I can rewrite a smaller file with just the subset of nodes I need. So, XMLReader seemed appealing for its supposed speed with $reader->expand().

Although I'm able to print out information from a test xml file with XMLReader, I'm not able to use $reader->expand(). It gives me a "Warning: DOM support is not enabled" message. However, in checking phpinfo(), I know that it is enabled with my hosting service. I've also checked the XML file to make sure it's valid. Here's the test code I've been using to try to get this to work.

$reader = new XMLReader();
$reader->open('http://www.shinyorb.com/static/开发者_运维知识库test.xml');

while ($reader->read()) {
 if ($reader->expand()) {           
      echo "worked <BR>";
 } 
  else {
      echo "bad <BR>";
  } 
}
$reader->close();

Any thoughts, leads, advice would be much appreciated!


I found that lowering PHP version (5.2.x -> 5.1.x) on a problem hosting fixes the problem. But this looks like hoster does not want to really fix his problem.

I have simpler test code which indicates the problem:

<?php
$xml = new XMLReader();
$xml->XML('<root/>');
$xml->read();
$obj = $xml->expand();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号