php - What would cause DOMNode::nodeValue to be empty? -
i'm trying parse document domdocument, , i'm having serious problems. created script runs fine on php 5.2.9, ripping out content using domnode::nodevalue. same script fails content on php 5.3.3 - though correctly navigates proper nodes extract content.
basically, code used looks this:
$dom = new domdocument(); $dom->loadhtml($data); $dom->preservewhitespace = false; $xpath = new domxpath($dom); $nodelist = $xpath->query($query); $value = $nodelist->item(0)->nodevalue;
i've checked make sure item(0) in fact node - it's there , of right type, nodevalue empty.
the script works on documents not others (on 5.3.3) - on 5.2.9 works on documents, returning proper nodevalue.
i seem have missed basic and/or bug (though if bug in php or libxml don't know). basically, issue fixed making sure data loaded loadhtml utf-8 encoded. mind you, it's not entire document needs utf-8 encoded - problem here there character in element wasn't in utf-8. threw off else in document handling.
what gets me meant document content thrown out - structure in place working normally. no errors or suggest content seen invalid.
Comments
Post a Comment