Skip to content

Instantly share code, notes, and snippets.

@MLKrisJohnson
Created December 11, 2018 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MLKrisJohnson/380bc1f177b6822a434878e6effe86f1 to your computer and use it in GitHub Desktop.
Save MLKrisJohnson/380bc1f177b6822a434878e6effe86f1 to your computer and use it in GitHub Desktop.
Log contents of an xmlDoc to NSLog
static void logXmlDocument(xmlDocPtr doc)
{
xmlChar *xmlbuff = nil;
int buffersize = 0;
xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
int remainingsize = buffersize;
xmlChar *p = xmlbuff;
char dumpbuff[80+1];
while (remainingsize > 0) {
size_t dumpsize = remainingsize < 80 ? remainingsize : 80;
memcpy(dumpbuff, p, dumpsize);
dumpbuff[dumpsize] = 0;
NSLog(@"#KJ |%s", dumpbuff);
p += dumpsize;
remainingsize -= dumpsize;
}
xmlFree(xmlbuff);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment