[JDEV] Does anyone use PHP for the client?
Geert-Jan Van den Bogaerde
gvdbogae at vub.ac.be
Tue Jan 8 09:16:22 CST 2002
On Tue, 2002-01-08 at 14:39, Antoine Maitre wrote:
> Ok,
>
> Since the data sent by the server is XML, I thought of
> using parsing functions to get all the stuff out. The
> problem I have is that when you have interesting data
> in the tag itself I can't use it. For example:
>
> <stream:stream
> xmlns:stream='http://etherx.jabber.org/streams'
> id='3C204F59' xmlns='jabber:client' ....
>
> I want to use the ID number. How do you access to that
> attribute. I tried the Expat functions, but you can
> only get the CDATA betwwen the tags.
IIRC (I haven't used PHP in a while), the SAX module for PHP passes a
dictionary containing the attribute name/value pairs to the element
start handler function, so you *can* access the attribute quite easily.
... the PHP docs at http://www.php.net/manual/en/ref.xml.php confirm
this, here's an example element start handler function:
function startElement($parser, $name, $attrs) {
/* $parser is a handler to the parser instance,
$name is the name of the element started
$attrs is a dictionary (associative array) with attribute values
*/
}
You do need to register your element handler functions with
xml_set_element_handler() first, of course.
Geert-Jan
[snipped]
More information about the JDev
mailing list