VirtualBox

source: vbox/trunk/src/libs/libxml2-2.6.30/doc/examples/io2.c@ 20364

最後變更 在這個檔案從20364是 6076,由 vboxsync 提交於 17 年 前

Merged dmik/s2 branch (r25959:26751) to the trunk.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Date Revision Author Id
檔案大小: 1.2 KB
 
1/**
2 * section: InputOutput
3 * synopsis: Output to char buffer
4 * purpose: Demonstrate the use of xmlDocDumpMemory
5 * to output document to a character buffer
6 * usage: io2
7 * test: io2 > io2.tmp ; diff io2.tmp io2.res ; rm -f io2.tmp
8 * author: John Fleck
9 * copy: see Copyright for the status of this software.
10 */
11
12#include <libxml/parser.h>
13
14#if defined(LIBXML_TREE_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
15int
16main(void)
17{
18
19 xmlNodePtr n;
20 xmlDocPtr doc;
21 xmlChar *xmlbuff;
22 int buffersize;
23
24 /*
25 * Create the document.
26 */
27 doc = xmlNewDoc(BAD_CAST "1.0");
28 n = xmlNewNode(NULL, BAD_CAST "root");
29 xmlNodeSetContent(n, BAD_CAST "content");
30 xmlDocSetRootElement(doc, n);
31
32 /*
33 * Dump the document to a buffer and print it
34 * for demonstration purposes.
35 */
36 xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
37 printf((char *) xmlbuff);
38
39 /*
40 * Free associated memory.
41 */
42 xmlFree(xmlbuff);
43 xmlFreeDoc(doc);
44
45 return (0);
46
47}
48#else
49#include <stdio.h>
50
51int
52main(void)
53{
54 fprintf(stderr,
55 "library not configured with tree and output support\n");
56 return (1);
57}
58#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette