/* Hack! ... Si no existe propiedad retorna "" */
char *xml_get_prop(xmlNode *node, char *nombre)
{
- if (xmlGetProp(node, nombre) == NULL) return "";
+ char *s;
+ if (xmlGetProp(node, nombre) == NULL) {
+ s = malloc(1);
+ s[0] = '\0';
+ return s;
+ }
return xmlGetProp(node, nombre);
}
{
t_Item *tmp;
int count;
+ char *prop;
if (size == -1) {
*cant = 0;
return NULL;
while (node) {
if (node->type == XML_ELEMENT_NODE) {
if (strcmp(node->name, "ITEMVENTA") == 0) {
- tmp[count].numero = atoi(xml_get_prop(node, "NroArtículo"));
- strcpy(tmp[count].cv, xml_get_prop(node, "CV"));
- strcpy(tmp[count].pvu, xml_get_prop(node, "PVU"));
+ prop = xml_get_prop(node, "NroArtículo");
+ tmp[count].numero = atoi(prop);
+ xmlFree(prop);
+ strcpy(tmp[count].cv, prop = xml_get_prop(node, "CV")); xmlFree(prop);
+ strcpy(tmp[count].pvu, prop = xml_get_prop(node, "PVU")); xmlFree(prop);
count++;
}
}
xmlDocPtr document;
xmlNode *node, *inicio;
int error = 0, cant_items;
+ char *prop;
EMUFS_REG_SIZE size;
t_LstFacturas *tmp;
EMUFS_REG_ID id; /*, *indices, indices_cant;*/
t_Factura fact;
void *save;
memset(&fact, '*', sizeof(t_Factura));
- fact.numero = atoi(xml_get_prop(node, "NroFac"));
- fact.procdoi = atof(xml_get_prop(node, "PorcDoI"));
- fact.numero_remito = atoi(xml_get_prop(node, "NroRemito"));
- strcpy(fact.emision, xml_get_prop(node, "FechaEmisión"));
- strcpy(fact.vencimiento, xml_get_prop(node, "FechaVto"));
- strcpy(fact.estado, xml_get_prop(node, "Estado"));
- strcpy(fact.fp, xml_get_prop(node, "FP"));
- strcpy(fact.ctacte, xml_get_prop(node, "NroCtaCte"));
- strcpy(fact.cheque, xml_get_prop(node, "NroCheque"));
+ prop = xml_get_prop(node, "NroFac");
+ fact.numero = atoi(prop); xmlFree(prop);
+ prop = xml_get_prop(node, "PorcDoI");
+ fact.procdoi = atof(prop); xmlFree(prop);
+ prop = xml_get_prop(node, "NroRemito");
+ fact.numero_remito = atoi(prop); xmlFree(prop);
+ strcpy(fact.emision, prop = xml_get_prop(node, "FechaEmisión")); xmlFree(prop);
+ strcpy(fact.vencimiento, prop = xml_get_prop(node, "FechaVto")); xmlFree(prop);
+ strcpy(fact.estado, prop = xml_get_prop(node, "Estado")); xmlFree(prop);
+ strcpy(fact.fp, prop = xml_get_prop(node, "FP")); xmlFree(prop);
+ strcpy(fact.ctacte, prop = xml_get_prop(node, "NroCtaCte")); xmlFree(prop);
+ strcpy(fact.cheque, prop = xml_get_prop(node, "NroCheque")); xmlFree(prop);
fact.nota = leer_nota(node);
fact.items = leer_items(node, &fact.cant_items, (tipo==3)?10:-1);