| Name | Size | Mode | Actions |
|---|---|---|---|
| images/ | - | 0755 | rm |
| apa.html | 2114 | 0644 | editdlrm |
| apb.html | 2026 | 0644 | editdlrm |
| apc.html | 3094 | 0644 | editdlrm |
| apd.html | 3232 | 0644 | editdlrm |
| ape.html | 3096 | 0644 | editdlrm |
| apf.html | 2949 | 0644 | editdlrm |
| apg.html | 3022 | 0644 | editdlrm |
| aph.html | 3600 | 0644 | editdlrm |
| api.html | 1899 | 0644 | editdlrm |
| ar01s02.html | 3298 | 0644 | editdlrm |
| ar01s03.html | 5718 | 0644 | editdlrm |
| ar01s04.html | 6223 | 0644 | editdlrm |
| ar01s05.html | 7422 | 0644 | editdlrm |
| ar01s06.html | 3849 | 0644 | editdlrm |
| ar01s07.html | 3866 | 0644 | editdlrm |
| ar01s08.html | 3894 | 0644 | editdlrm |
| ar01s09.html | 7603 | 0644 | editdlrm |
| includeaddattribute.c | 1136 | 0644 | editdlrm |
| includeaddkeyword.c | 1320 | 0644 | editdlrm |
| includeconvert.c | 1808 | 0644 | editdlrm |
| includegetattribute.c | 1171 | 0644 | editdlrm |
| includekeyword.c | 1351 | 0644 | editdlrm |
| includexpath.c | 1491 | 0644 | editdlrm |
| index.html | 5930 | 0644 | editdlrm |
| ix01.html | 2545 | 0644 | editdlrm |
| xmltutorial.pdf | 51709 | 0644 | editdlrm |
/usr/share/doc/libxml2-devel/tutorial/ar01s03.html (5718B)
Parsing the file requires only the name of the file and a single function call, plus error checking. Full code: Appendix C, Code for Keyword Example
xmlDocPtr doc;
xmlNodePtr cur;
doc = xmlParseFile(docname);
if (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n");
return;
}
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return;
}
if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
fprintf(stderr,"document of the wrong type, root node != story");
xmlFreeDoc(doc);
return;
}
| Declare the pointer that will point to your parsed document. | ||||
| Declare a node pointer (you'll need this in order to interact with individual nodes). | ||||
| Check to see that the document was successfully parsed. If it was not, libxml will at this point register an error and stop.
| ||||
| Retrieve the document's root element. | ||||
| Check to make sure the document actually contains something. | ||||
| In our case, we need to make sure the document is the right type. "story" is the root type of the documents used in this tutorial. | ||||