diff --git a/CHANGES b/CHANGES index d706ff9..098fb6a 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,8 @@ CHANGES IN Mini-XML 1.1 capped at 16383, 255, and 255 bytes, respectively. - Added a new mxmlLoadString() function for loading an XML node tree from a string. + - Added a new mxmlSaveString() function for saving an + XML node tree to a string. - Add emulation of strdup() if the local platform does not provide the function. diff --git a/Makefile.in b/Makefile.in index 3750590..e5f585e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -# "$Id: Makefile.in,v 1.10 2003/07/20 13:41:17 mike Exp $" +# "$Id: Makefile.in,v 1.11 2003/07/20 13:49:09 mike Exp $" # # Makefile for mini-XML, a small XML-like file parsing library. # @@ -189,13 +189,19 @@ mxmldoc.o: mxml.h testmxml: libmxml.a testmxml.o $(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a @echo Testing library... - ./testmxml test.xml >temp1.xml - ./testmxml temp1.xml >temp2.xml + ./testmxml test.xml >temp1.xml 2>temp1s.xml + ./testmxml temp1.xml >temp2.xml 2>temp2s.xml @if cmp temp1.xml temp2.xml; then \ - echo Test passed!; \ - $(RM) temp1.xml temp2.xml; \ + echo File test passed!; \ + $(RM) temp2.xml temp2s.xml; \ else \ - echo Test failed!; \ + echo File test failed!; \ + fi + @if cmp temp1.xml temp1s.xml; then \ + echo String test passed!; \ + $(RM) temp1.xml temp1s.xml; \ + else \ + echo String test failed!; \ fi testmxml.o: mxml.h @@ -218,5 +224,5 @@ $(OBJS): Makefile config.h # -# End of "$Id: Makefile.in,v 1.10 2003/07/20 13:41:17 mike Exp $". +# End of "$Id: Makefile.in,v 1.11 2003/07/20 13:49:09 mike Exp $". # diff --git a/testmxml.c b/testmxml.c index 52c2719..9d6f315 100644 --- a/testmxml.c +++ b/testmxml.c @@ -1,5 +1,5 @@ /* - * "$Id: testmxml.c,v 1.10 2003/07/20 13:41:17 mike Exp $" + * "$Id: testmxml.c,v 1.11 2003/07/20 13:49:09 mike Exp $" * * Test program for mini-XML, a small XML-like file parsing library. * @@ -50,6 +50,7 @@ main(int argc, /* I - Number of command-line args */ FILE *fp; /* File to read */ mxml_node_t *tree, /* XML tree */ *node; /* Node which should be in test.xml */ + char buffer[16384]; /* Save string */ static const char *types[] = /* Strings for node types */ { "MXML_ELEMENT", @@ -287,6 +288,13 @@ main(int argc, /* I - Number of command-line args */ mxmlSaveFile(tree, stdout, whitespace_cb); + /* + * Save the XML tree to a string and print it... + */ + + if (mxmlSaveString(tree, buffer, sizeof(buffer), whitespace_cb) > 0) + fputs(buffer, stderr); + /* * Delete the tree and return... */ @@ -384,5 +392,5 @@ whitespace_cb(mxml_node_t *node, /* I - Element node */ /* - * End of "$Id: testmxml.c,v 1.10 2003/07/20 13:41:17 mike Exp $". + * End of "$Id: testmxml.c,v 1.11 2003/07/20 13:49:09 mike Exp $". */