Wednesday, 31 December 2014

PHP XML reader not finding node with hyphen



I have the following PHP which works exactly as it should and finds all 'Widgets' in my xml document:



if($reader->nodeType == XMLREADER::ELEMENT && $reader->localName == 'manufacturer'){
$reader->read();
if($reader->value == 'Widget'){
echo 'congrats you have found the widget';
}


But when I try the following, I get no results, and I know "blue-widget" to exist several times in the xml document in the manufacturer node:



if($reader->nodeType == XMLREADER::ELEMENT && $reader->localName == 'manufacturer'){
$reader->read();
if($reader->value == 'blue-widget'){
echo 'congrats you have found the widget';
}


Does this have something to do with the hyphen in the manufacturer name? I also cannot seem to find the "blue-widget" by any other attribute, yet any other named product I try to extract can be found just find. Its as if XML Reader is not seeing the product nodes that contain "blue-widget".


No comments:

Post a Comment