Quickie: Why doesn't can't I get a value from this array?
| From: | April | Date: | Mon, 08 Jan 2001 20:36:31 +0000 |
| Subject: | Quickie: Why doesn't can't I get a value from this array? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-33306@lists.php.net to get a copy of this message | ||
Hi, I'm using PHP to process some XML, and I can't figure out how to access
the attributes of the tag. Yeah, yeah, it's not brain surgery or anything,
but there's a reason I'm not a brain surgeon.
from documentation:
The third parameter, attribs, contains an associative array with the
element's attributes (if any). The keys of this array are the attribute
names, the values are the attribute values. Attribute names are case-folded
on the same criteria as element names. Attribute values are not case-folded.
my code snippet:
function startElementHandler($parser, $name, $attribs) {
if ($name == "NARROW") {
echo("<br><br>A narrow.<br>");
$array_element = $attribs["r:resource"];
echo("r:resource of a narrow: $array_element <br><br>");
}
}
and the xml looks like this:
<Topic r:id="Top">
<tag catid="1"/>
<d:Title>Top</d:Title>
<narrow r:resource="Top/Arts"/>
<narrow r:resource="Top/Business"/>
</Topic>
My error code looks like:
Warning: Undefined index: r:resource in
c:\apache\htdocs\searchengine\categories.php on line 26
(over and over again, of course)
But, count($attribs) returns 1.
Anyway, any help would be greatly appreciated.