Re: [xml] libxml2 API crazy?
- From: Callum Gibson <callum_r_gibson yahoo com au>
- To: Nikita Churaev <lamefun x0r gmail com>
- Cc: xml gnome org, "Eric S. Eberhard" <eric vicsmba com>, veillard redhat com
- Subject: Re: [xml] libxml2 API crazy?
- Date: Sat, 4 May 2013 14:15:49 +1000
Thanks for that.
I guess my only comment is that doc->type and node->type are there for
a reason. But I agree it's a bit disingenuous to be traversing up a tree
via ->parent and discover that you've hit a node which is actually a xmlDoc.
In practice this means always having to have a special case test for
node->parent == node->doc or node->parent->type == XML_ELEMENT_NODE/XML_DOCUMENT_NODE and so on before you
assume it really is a xmlNode.
I'm not even sure why the root node parent of a doc points to the xmlDoc
given that there is a node->doc value to use if you want it.
On 04May13 07:35, Nikita Churaev wrote:
}this gives out an error:
}
}#include <libxml/parser.h>
}#include <libxml/tree.h>
}#include <stdio.h>
}
}int
}main (int argc, char** argv)
}{
} xmlDocPtr doc = xmlReadMemory("<doc/>", 6, "egg.xml", NULL, 0);
}
} /* XmlNode */ /* XmlDoc */
} printf("%s\n", (doc->children->parent == doc) ? "true" : "false");
} return 0;
}}
}
}and this crashes on my machine (as xmlDoc has different fields than
}xmlName):
}
}#include <libxml/parser.h>
}#include <libxml/tree.h>
}#include <stdio.h>
}
}int
}main (int argc, char** argv)
}{
} xmlDocPtr doc = xmlReadMemory("<doc/>", 6, "egg.xml", NULL, 0);
}
} if (doc->children->parent->ns && doc->children->parent->ns->href)
} printf("%s\n", doc->children->parent->ns->href);
}
} return 0;
}}
--
Callum Gibson @ home
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]