PDA

View Full Version : php dom/xml difficulty ARGHHH



Snx
October 21st, 2005, 01:41 AM
trying to wrap my head around why i cant access the textContent of the firstChild element in an xml file using php's dom... will return the element id's however... does anyone know why???

xml file:


<?xml version="1.0"?>
<Index>
<Item>
<Date>20051013</Date>
<Title>Massive Stars Can Grow Near Black Holes</Title>
</Item>
<Item>
<Date>20051019</Date>
<Title>Researchers Study Changes in Hurricanes</Title>
</Item>
</Index>





<?php
$dom = new DOMDocument;
$dom->load('test.xml');

//$Items = $dom->documentElement->getElementsByTagName('Item');
foreach ($Items as $item) {
print $item->firstChild->textContent;
print '<br />';
if($item->firstChild->textContent == '20051019')
{
//$item->parentNode->removeChild($item);
}
}
//$dom->saveXML();
print '<br /> done.';
?>


thx!
snx