[Expat-discuss] question about parsing
gmane
alexander.nikiforov at vocord.ru
Sat Jun 25 11:01:51 CEST 2011
I All,
I have this file
===================
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<s:Header>
<a:Action
s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>
<a:MessageID>urn:uuid:6973e851-f104-41e0-ba50-6e46ef649115</a:MessageID>
<a:ReplyTo>
<a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
</a:ReplyTo>
<a:To
s:mustUnderstand="1">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>
</s:Header>
<s:Body>
<Probe xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery">
<d:Types xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"
xmlns:dp0="http://www.onvif.org/ver10/network/wsdl">dp0:NetworkVideoTransmitter</d:Types>
</Probe>
</s:Body>
</s:Envelope>
===================
but simple parser give me
======================
s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'
xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'
s:Header
a:Action s:mustUnderstand='1'
a:MessageID
a:ReplyTo
a:Address
a:To s:mustUnderstand='1'
s:Body
Probe xmlns='http://schemas.xmlsoap.org/ws/2005/04/discovery'
d:Types xmlns:d='http://schemas.xmlsoap.org/ws/2005/04/discovery'
xmlns:dp0='http://www.onvif.org/ver10/network/wsdl'
======================
Why libexpat dont parse dp0:NetworkVideoTransmitter string ????
some sources
init with
==============================
p3_od->p = XML_ParserCreate(NULL);
//p3_od->p = XML_ParserCreateNS(NULL, ' ');
if( p3_od->p == NULL ) {
fprintf(stderr, "Couldn't allocate memory for parser\n");
exit(-1);
}
XML_SetElementHandler(p3_od->p, start, end);
==============================
parse with
===============================
static void start(void *data, const char *el, const char **attr)
{
int i;
p3_onvif_t *p3_od = &p3_onvif_data;
for(i = 0; i < p3_od->Depth; i++)
printf(" ");
printf("%s", el);
/* attr is array of name/value pairs, terminated by 0; */
/* names and values are 0 terminated. */
for (i = 0; attr[i]; i += 2) {
printf(" %s='%s'", attr[i], attr[i + 1]);
}
printf("\n");
p3_od->Depth++;
} /* End of start handler */
static void end(void *data, const char *el)
{
p3_onvif_t *p3_od = &p3_onvif_data;
p3_od->Depth--;
} /* End of end handler */
===============================
More information about the Expat-discuss
mailing list