I'm parsing some xml files in C using libxml library. I want to compare two xmlnodes to see whether they contain the same data or not. Is there any function available to do so?
Asked
Active
Viewed 1,414 times
2 Answers
1
The libxml API docs seem reasonable and suggest that xmlBufGetNodeContent and xmlBufContent might do what you want.
xmlNode node1, node2;
......
xmlBuf buf;
xmlChar* content1 = NULL;
xmlChar* content2 = NULL;
if (xmlBufGetNodeContent(&buf, &node1) == 0) {
content1 = xmlBufContent(&buf);
}
if (xmlBufGetNodeContent(&buf, &node2) == 0) {
content2 = xmlBufContent(&buf);
}
if (strcmp(content1, content2) == 0) {
/* nodes match */
}

simonc
- 41,632
- 12
- 85
- 103
0
I don't think the api calls xmlBufGetNodeContent and xmlBufContent are any more valid. As the datatype involved in those calls - xmlBufPtr are no more available , atleast not on libxml2 2.7.6 I used a different api call xmlNodeDump or xmlNodeGetContent. hope it helps others with similar question.

siddharth
- 171
- 1
- 6