[xml] Getting the element's attributes with SAX2



Hi:

I'm using SAX2 interface in my parsing xml program.
When I use version 1 I read OK the attributes for every element with xmlSAX2StartElement

But when I use the version 2 ( putting XML_SAX2_MAGIC in /initialized/ register in my xmlSAXHandler), I can read the /localneme/, /prefix /and /namespaces /but I have problems to achieve others attributes.
I use the xmlSAX2StartElementNs function.

How could I get them?

------------------

My programs parse xml data in multithread without using DOM.
I initialize my  program:
void my_xml_init(void)
{
   xmlInitParser();
   xmlSAX2InitDefaultSAXHandler (mySAXHandler, 1);
}

and my parsing is:

void my_parsing(...)
{
...

xmlSAXUserParseMemory(mySAXHandler, my_ctx, inXMLText, inXMLTextLength);

...
}


And my  xmlSAX2StartElementNs:

void StartElement_Ns (void * ctx, const xmlChar * localname,
                               const xmlChar * prefix,
                               const xmlChar * URI,
                               int nb_namespaces,
                               const xmlChar ** namespaces,
                               int nb_attributes,
                               int nb_defaulted,
                               const xmlChar ** attributes)
{
   ...
   strcpy(ctx->my_attributes[i],attributes[i])

   ...
}

Is anything  wrong?

Thank for all
Antonio

------------------------------------------------------------------
This e-mail and the documents attached are confidential and intended solely
for the addressee; it may also be privileged. If you receive this e-mail
in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the sender does
not warrant that this transmission is virus-free and will not be liable for
any damages resulting from any virus transmitted.

Este mensaje y los ficheros adjuntos pueden contener informacion
confidencial destinada solamente a la(s) persona(s) mencionadas
anteriormente. Pueden estar protegidos por secreto profesional Si usted
recibe este correo electronico por error, gracias de informar inmediatamente
al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos
Origin no se hace responsable por su contenido. Su contenido no constituye
ningun compromiso para el grupo Atos Origin, salvo ratificacion escrita por
ambas partes.
Aunque se esfuerza al maximo por mantener su red libre de virus, el emisor
no puede garantizar nada al respecto y no sera responsable de cualesquiera
danos que puedan resultar de una transmision de virus
------------------------------------------------------------------




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]