Created
December 11, 2018 20:53
-
-
Save MLKrisJohnson/380bc1f177b6822a434878e6effe86f1 to your computer and use it in GitHub Desktop.
Log contents of an xmlDoc to NSLog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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