1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

doc/tutorial/xmltutorial.xml doc/tutorial/includekeyword.c

Sun Dec 15 21:27:30 MST 2002 John Fleck <jfleck@inkstain.net>

	* doc/tutorial/xmltutorial.xml
	* doc/tutorial/includekeyword.c
	* doc/tutorial/includegetattribute.c
	plus generated html and pdf
	Adding fix from Niraj Tolia to tutorial to properly free memory.
This commit is contained in:
MST 2002 John Fleck
2002-12-16 04:34:57 +00:00
committed by John Fleck
parent da46d2d31e
commit 44aacb3404
12 changed files with 57 additions and 27 deletions

View File

@ -1,3 +1,12 @@
Sun Dec 15 21:27:30 MST 2002 John Fleck <jfleck@inkstain.net>
* doc/tutorial/xmltutorial.xml
* doc/tutorial/includekeyword.c
* doc/tutorial/includegetattribute.c
plus generated html and pdf
Adding fix from Niraj Tolia to tutorial to properly free memory.
Mon Dec 16 00:34:25 CET 2002 Daniel Veillard <daniel@veillard.com> Mon Dec 16 00:34:25 CET 2002 Daniel Veillard <daniel@veillard.com>
* xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: added * xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: added

View File

@ -10,11 +10,14 @@
void void
parseStory (xmlDocPtr doc, xmlNodePtr cur) { parseStory (xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *key;
cur = cur-&gt;xmlChildrenNode; cur = cur-&gt;xmlChildrenNode;
while (cur != NULL) { while (cur != NULL) {
if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;keyword&quot;))) { if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;keyword&quot;))) {
printf(&quot;keyword: %s\n&quot;, xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1)); key = xmlNodeListGetString(doc, cur-&gt;xmlChildrenNode, 1);
} printf(&quot;keyword: %s\n&quot;, key);
xmlFree(key);
}
cur = cur-&gt;next; cur = cur-&gt;next;
} }
return; return;
@ -30,7 +33,6 @@ parseDoc(char *docname) {
if (doc == NULL ) { if (doc == NULL ) {
fprintf(stderr,&quot;Document not parsed successfully. \n&quot;); fprintf(stderr,&quot;Document not parsed successfully. \n&quot;);
xmlFreeDoc(doc);
return; return;
} }

View File

@ -10,14 +10,17 @@
void void
getReference (xmlDocPtr doc, xmlNodePtr cur) { getReference (xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *uri;
cur = cur-&gt;xmlChildrenNode; cur = cur-&gt;xmlChildrenNode;
while (cur != NULL) { while (cur != NULL) {
if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;reference&quot;))) { if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;reference&quot;))) {
printf(&quot;uri: %s\n&quot;, xmlGetProp(cur, &quot;uri&quot;)); uri = xmlGetProp(cur, &quot;uri&quot;);
} printf(&quot;uri: %s\n&quot;, uri);
xmlFree(uri);
}
cur = cur-&gt;next; cur = cur-&gt;next;
} }
return; return;
} }

View File

@ -1,5 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>G. Acknowledgements</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="up" href="index.html" title="Libxml Tutorial"><link rel="previous" href="apf.html" title="F. Code for Encoding Conversion Example"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">G. Acknowledgements</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apf.html">Prev</a><EFBFBD></td><th width="60%" align="center"><EFBFBD></th><td width="20%" align="right"><EFBFBD></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><h2 class="title"><a name="id2802385"></a>G. Acknowledgements</h2></div></div><p>A number of people have generously offered feedback, code and <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>G. Acknowledgements</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="up" href="index.html" title="Libxml Tutorial"><link rel="previous" href="apf.html" title="F. Code for Encoding Conversion Example"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">G. Acknowledgements</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apf.html">Prev</a><EFBFBD></td><th width="60%" align="center"><EFBFBD></th><td width="20%" align="right"><EFBFBD></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><h2 class="title"><a name="id2871832"></a>G. Acknowledgements</h2></div></div><p>A number of people have generously offered feedback, code and
suggested improvements to this tutorial. In no particular order: suggested improvements to this tutorial. In no particular order:
</p><table class="simplelist" border="0" summary="Simple list"><tr><td>Daniel Veillard</td></tr><tr><td>Marcus Labib Iskander</td></tr><tr><td>Christopher R. Harris</td></tr><tr><td>Igor Zlatkovic</td></tr></table><p> </p><table class="simplelist" border="0" summary="Simple list"><tr><td>Daniel Veillard</td></tr><tr><td>Marcus Labib Iskander</td></tr><tr><td>Christopher R. Harris</td></tr><tr><td>Igor Zlatkovic</td></tr><tr><td>Niraj Tolia</td></tr></table><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apf.html">Prev</a><EFBFBD></td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"><EFBFBD></td></tr><tr><td width="40%" align="left" valign="top">F. Code for Encoding Conversion Example<6C></td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"><EFBFBD></td></tr></table></div></body></html> </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apf.html">Prev</a><EFBFBD></td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"><EFBFBD></td></tr><tr><td width="40%" align="left" valign="top">F. Code for Encoding Conversion Example<6C></td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"><EFBFBD></td></tr></table></div></body></html>

View File

@ -32,14 +32,14 @@
interact with individual nodes).</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkparseerror"><img src="images/callouts/4.png" alt="4" border="0"></a> </td><td valign="top" align="left"><p>Check to see that the document was successfully parsed. If it interact with individual nodes).</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkparseerror"><img src="images/callouts/4.png" alt="4" border="0"></a> </td><td valign="top" align="left"><p>Check to see that the document was successfully parsed. If it
was not, libxml will at this point was not, libxml will at this point
register an error and stop. register an error and stop.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th>Note</th></tr><tr><td colspan="2" align="left" valign="top"><p>One common example of an error at this point is improper </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>One common example of an error at this point is improper
handling of encoding. The XML standard requires handling of encoding. The XML standard requires
documents stored with an encoding other than UTF-8 or UTF-16 to documents stored with an encoding other than UTF-8 or UTF-16 to
contain an explicit declaration of their encoding. If the contain an explicit declaration of their encoding. If the
declaration is there, libxml will declaration is there, libxml will
automatically perform the necessary conversion to UTF-8 for automatically perform the necessary conversion to UTF-8 for
you. More information on XML's encoding you. More information on XML's encoding
requirements is contained in the <a href="http://www.w3.org/TR/REC-xml#charencoding" target="_top">standard</a>.</p></td></tr></table></div><p> requirements is contained in the <a href="http://www.w3.org/TR/REC-xml#charencoding" target="_top">standard</a>.</p></div><p>
</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#getrootelement"><img src="images/callouts/5.png" alt="5" border="0"></a> </td><td valign="top" align="left"><p>Retrieve the document's root element.</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkemptyerror"><img src="images/callouts/6.png" alt="6" border="0"></a> </td><td valign="top" align="left"><p>Check to make sure the document actually contains something.</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkroottype"><img src="images/callouts/7.png" alt="7" border="0"></a> </td><td valign="top" align="left"><p>In our case, we need to make sure the document is the right </p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#getrootelement"><img src="images/callouts/5.png" alt="5" border="0"></a> </td><td valign="top" align="left"><p>Retrieve the document's root element.</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkemptyerror"><img src="images/callouts/6.png" alt="6" border="0"></a> </td><td valign="top" align="left"><p>Check to make sure the document actually contains something.</p></td></tr><tr><td width="5%" valign="top" align="left"><a href="#checkroottype"><img src="images/callouts/7.png" alt="7" border="0"></a> </td><td valign="top" align="left"><p>In our case, we need to make sure the document is the right
type. &quot;story&quot; is the root type of the documents used in this type. &quot;story&quot; is the root type of the documents used in this
tutorial.</p></td></tr></table></div><p> tutorial.</p></td></tr></table></div><p>

View File

@ -11,14 +11,17 @@
void void
getReference (xmlDocPtr doc, xmlNodePtr cur) { getReference (xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *uri;
cur = cur-&gt;xmlChildrenNode; cur = cur-&gt;xmlChildrenNode;
while (cur != NULL) { while (cur != NULL) {
if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;reference&quot;))) { if ((!xmlStrcmp(cur-&gt;name, (const xmlChar *)&quot;reference&quot;))) {
<a name="getattributevalue"></a><img src="images/callouts/1.png" alt="1" border="0"> printf(&quot;uri: %s\n&quot;, xmlGetProp(cur, &quot;uri&quot;)); <a name="getattributevalue"></a><img src="images/callouts/1.png" alt="1" border="0"> uri = xmlGetProp(cur, &quot;uri&quot;);
} printf(&quot;uri: %s\n&quot;, uri);
xmlFree(uri);
}
cur = cur-&gt;next; cur = cur-&gt;next;
} }
return; return;
} }
</pre><p> </pre><p>
@ -26,10 +29,10 @@ getReference (xmlDocPtr doc, xmlNodePtr cur) {
The key function is <tt><a href="http://xmlsoft.org/html/libxml-tree.html#XMLGETPROP" target="_top">xmlGetProp</a></tt>, which returns an The key function is <tt><a href="http://xmlsoft.org/html/libxml-tree.html#XMLGETPROP" target="_top">xmlGetProp</a></tt>, which returns an
<tt>xmlChar</tt> containing the attribute's value. In this case, <tt>xmlChar</tt> containing the attribute's value. In this case,
we just print it out. we just print it out.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th>Note</th></tr><tr><td colspan="2" align="left" valign="top"><p> </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
If you are using a DTD that declares a fixed or If you are using a DTD that declares a fixed or
default value for the attribute, this function will retrieve it. default value for the attribute, this function will retrieve it.
</p></td></tr></table></div><p> </p></div><p>
</p></td></tr></table></div><p> </p></td></tr></table></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar01s06.html">Prev</a><EFBFBD></td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"><EFBFBD><a accesskey="n" href="ar01s08.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Writing Attribute<74></td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"><EFBFBD>Encoding Conversion</td></tr></table></div></body></html> </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar01s06.html">Prev</a><EFBFBD></td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"><EFBFBD><a accesskey="n" href="ar01s08.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Writing Attribute<74></td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"><EFBFBD>Encoding Conversion</td></tr></table></div></body></html>

View File

@ -18,14 +18,14 @@
different character formats with ability to convert from any to any. While different character formats with ability to convert from any to any. While
the actual number of supported formats varies between implementations, every the actual number of supported formats varies between implementations, every
iconv implementation is almost guaranteed to iconv implementation is almost guaranteed to
support every format anyone has ever heard of.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td><th>Warning</th></tr><tr><td colspan="2" align="left" valign="top"><p>A common mistake is to use different formats for the internal data support every format anyone has ever heard of.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>A common mistake is to use different formats for the internal data
in different parts of one's code. The most common case is an application in different parts of one's code. The most common case is an application
that assumes ISO-8859-1 to be the internal data format, combined with that assumes ISO-8859-1 to be the internal data format, combined with
libxml, which assumes UTF-8 to be the libxml, which assumes UTF-8 to be the
internal data format. The result is an application that treats internal internal data format. The result is an application that treats internal
data differently, depending on which code section is executing. The one or data differently, depending on which code section is executing. The one or
the other part of code will then, naturally, misinterpret the data. the other part of code will then, naturally, misinterpret the data.
</p></td></tr></table></div><p>This example constructs a simple document, then adds content provided </p></div><p>This example constructs a simple document, then adds content provided
at the command line to the document's root element and outputs the results at the command line to the document's root element and outputs the results
to <tt>stdout</tt> in the proper encoding. For this example, we to <tt>stdout</tt> in the proper encoding. For this example, we
use ISO-8859-1 encoding. The encoding of the string input at the command use ISO-8859-1 encoding. The encoding of the string input at the command

View File

@ -8,14 +8,17 @@
void void
getReference (xmlDocPtr doc, xmlNodePtr cur) { getReference (xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *uri;
cur = cur->xmlChildrenNode; cur = cur->xmlChildrenNode;
while (cur != NULL) { while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) {
printf("uri: %s\n", xmlGetProp(cur, "uri")); uri = xmlGetProp(cur, "uri");
} printf("uri: %s\n", uri);
xmlFree(uri);
}
cur = cur->next; cur = cur->next;
} }
return; return;
} }

View File

@ -8,11 +8,14 @@
void void
parseStory (xmlDocPtr doc, xmlNodePtr cur) { parseStory (xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *key;
cur = cur->xmlChildrenNode; cur = cur->xmlChildrenNode;
while (cur != NULL) { while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) {
printf("keyword: %s\n", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
} printf("keyword: %s\n", key);
xmlFree(key);
}
cur = cur->next; cur = cur->next;
} }
return; return;
@ -28,7 +31,6 @@ parseDoc(char *docname) {
if (doc == NULL ) { if (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n"); fprintf(stderr,"Document not parsed successfully. \n");
xmlFreeDoc(doc);
return; return;
} }

View File

@ -1,5 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Libxml Tutorial</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="next" href="ar01s02.html" title="Data Types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Libxml Tutorial</th></tr><tr><td width="20%" align="left"><EFBFBD></td><th width="60%" align="center"><EFBFBD></th><td width="20%" align="right"><EFBFBD><a accesskey="n" href="ar01s02.html">Next</a></td></tr></table><hr></div><div class="article" lang="en"><div class="titlepage"><div><h1 class="title"><a name="id2800880"></a>Libxml Tutorial</h1></div><div><div class="author"><h3 class="author">John Fleck</h3></div></div><div><p class="copyright">Copyright <20> 2002 John Fleck</p></div><div><div class="revhistory"><table border="1" width="100%" summary="Revision history"><tr><th align="left" valign="top" colspan="2"><b>Revision History</b></th></tr><tr><td align="left">Revision 1</td><td align="left">June 4,2002</td></tr><tr><td align="left">Revision 2</td><td align="left">June 12, 2002</td></tr><tr><td align="left">Revision 3</td><td align="left">Aug. 31, 2002</td></tr><tr><td align="left">Revision 4</td><td align="left">Nov. 10, 2002</td></tr></table></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="index.html#introduction">Introduction</a></dt><dt><a href="ar01s02.html">Data Types</a></dt><dt><a href="ar01s03.html">Parsing the file</a></dt><dt><a href="ar01s04.html">Retrieving Element Content</a></dt><dt><a href="ar01s05.html">Writing element content</a></dt><dt><a href="ar01s06.html">Writing Attribute</a></dt><dt><a href="ar01s07.html">Retrieving Attributes</a></dt><dt><a href="ar01s08.html">Encoding Conversion</a></dt><dt>A. <a href="apa.html">Sample Document</a></dt><dt>B. <a href="apb.html">Code for Keyword Example</a></dt><dt>C. <a href="apc.html">Code for Add Keyword Example</a></dt><dt>D. <a href="apd.html">Code for Add Attribute Example</a></dt><dt>E. <a href="ape.html">Code for Retrieving Attribute Value Example</a></dt><dt>F. <a href="apf.html">Code for Encoding Conversion Example</a></dt><dt>G. <a href="apg.html">Acknowledgements</a></dt></dl></div><div class="abstract"><p class="title"><b>Abstract</b></p><p>Libxml is a freely licensed C language library for handling <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Libxml Tutorial</title><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><link rel="home" href="index.html" title="Libxml Tutorial"><link rel="next" href="ar01s02.html" title="Data Types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Libxml Tutorial</th></tr><tr><td width="20%" align="left"><EFBFBD></td><th width="60%" align="center"><EFBFBD></th><td width="20%" align="right"><EFBFBD><a accesskey="n" href="ar01s02.html">Next</a></td></tr></table><hr></div><div class="article" lang="en"><div class="titlepage"><div><h1 class="title"><a name="id2803514"></a>Libxml Tutorial</h1></div><div><div class="author"><h3 class="author">John Fleck</h3></div></div><div><p class="copyright">Copyright <20> 2002 John Fleck</p></div><div><div class="revhistory"><table border="1" width="100%" summary="Revision history"><tr><th align="left" valign="top" colspan="2"><b>Revision History</b></th></tr><tr><td align="left">Revision 1</td><td align="left">June 4, 2002</td></tr><tr><td align="left">Revision 2</td><td align="left">June 12, 2002</td></tr><tr><td align="left">Revision 3</td><td align="left">Aug. 31, 2002</td></tr><tr><td align="left">Revision 4</td><td align="left">Nov. 10, 2002</td></tr><tr><td align="left">Revision 5</td><td align="left">Dec. 15, 2002</td></tr></table></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="index.html#introduction">Introduction</a></dt><dt><a href="ar01s02.html">Data Types</a></dt><dt><a href="ar01s03.html">Parsing the file</a></dt><dt><a href="ar01s04.html">Retrieving Element Content</a></dt><dt><a href="ar01s05.html">Writing element content</a></dt><dt><a href="ar01s06.html">Writing Attribute</a></dt><dt><a href="ar01s07.html">Retrieving Attributes</a></dt><dt><a href="ar01s08.html">Encoding Conversion</a></dt><dt>A. <a href="apa.html">Sample Document</a></dt><dt>B. <a href="apb.html">Code for Keyword Example</a></dt><dt>C. <a href="apc.html">Code for Add Keyword Example</a></dt><dt>D. <a href="apd.html">Code for Add Attribute Example</a></dt><dt>E. <a href="ape.html">Code for Retrieving Attribute Value Example</a></dt><dt>F. <a href="apf.html">Code for Encoding Conversion Example</a></dt><dt>G. <a href="apg.html">Acknowledgements</a></dt></dl></div><div class="abstract"><p class="title"><b>Abstract</b></p><p>Libxml is a freely licensed C language library for handling
XML, portable across a large number of platforms. This XML, portable across a large number of platforms. This
tutorial provides examples of its basic functions.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="introduction"></a>Introduction</h2></div></div><p>Libxml is a C language library implementing functions for reading, tutorial provides examples of its basic functions.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="introduction"></a>Introduction</h2></div></div><p>Libxml is a C language library implementing functions for reading,
creating and manipulating XML data. This tutorial creating and manipulating XML data. This tutorial

Binary file not shown.

View File

@ -37,6 +37,10 @@
<revnumber>4</revnumber> <revnumber>4</revnumber>
<date>Nov. 10, 2002</date> <date>Nov. 10, 2002</date>
</revision> </revision>
<revision>
<revnumber>5</revnumber>
<date>Dec. 15, 2002</date>
</revision>
</revhistory> </revhistory>
</articleinfo> </articleinfo>
<abstract> <abstract>
@ -381,14 +385,17 @@ parseStory (xmlDocPtr doc, xmlNodePtr cur, char *keyword) {
void void
getReference (xmlDocPtr doc, xmlNodePtr cur) { getReference (xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *uri;
cur = cur->xmlChildrenNode; cur = cur->xmlChildrenNode;
while (cur != NULL) { while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"reference"))) {
<co id="getattributevalue" /> printf("uri: %s\n", xmlGetProp(cur, "uri")); <co id="getattributevalue" /> uri = xmlGetProp(cur, "uri");
} printf("uri: %s\n", uri);
xmlFree(uri);
}
cur = cur->next; cur = cur->next;
} }
return; return;
} }
</programlisting> </programlisting>
@ -555,6 +562,7 @@ getReference (xmlDocPtr doc, xmlNodePtr cur) {
<member>Marcus Labib Iskander</member> <member>Marcus Labib Iskander</member>
<member>Christopher R. Harris</member> <member>Christopher R. Harris</member>
<member>Igor Zlatkovic</member> <member>Igor Zlatkovic</member>
<member>Niraj Tolia</member>
</simplelist> </simplelist>
</para> </para>
</appendix> </appendix>