Re: Quickie: Why doesn't can't I get a value from this array?

From: Date: Mon, 08 Jan 2001 21:51:21 +0000
Subject: Re: Quickie: Why doesn't can't I get a value from this array?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33327@lists.php.net to get a copy of this message
I don't think you can have a ":" in a NAME... At least, not in HTML. Not sure about XML, but try it without. ----- Original Message ----- From: "April" <april@farstrider.org> Newsgroups: php.general Sent: Monday, January 08, 2001 2:43 PM Subject: [PHP] Quickie: Why doesn't can't I get a value from this array? > 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. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#33327) next »