README - xmlparser - XML parser (HTM) git clone git://git.codemadness.org/xmlparser (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- README (1921B) --- 1 XML parser 2 ---------- 3 4 A small XML parser. 5 6 7 Dependencies 8 ------------ 9 10 - C compiler (ANSI). 11 12 13 Features 14 -------- 15 16 - Relatively small parser. 17 - Pretty simple API. 18 - Pretty fast. 19 - Portable 20 - No dynamic memory allocation. 21 22 23 Supports 24 -------- 25 26 - Tags in short-form (<img src="lolcat.jpg" title="Meow" />). 27 - Tag attributes. 28 - Short attributes without an explicitly set value (<input type="checkbox" checked />). 29 - Comments 30 - CDATA sections. 31 - Helper function (xml_entitytostr) to convert XML 1.0 / HTML 2.0 named entities 32 and numeric entities to UTF-8. 33 - Reading XML from a fd, string buffer or implement a custom reader: 34 see: XMLParser.getnext or GETNEXT() macro. 35 36 37 Caveats 38 ------- 39 40 - It is not a compliant XML parser. 41 - Performance: data is buffered even if a handler is not set: to make parsing 42 faster change this code from xml.c. 43 - The XML is not checked for errors so it will continue parsing XML data, this 44 is by design. 45 - Internally fixed-size buffers are used, callbacks like XMLParser.xmldata are 46 called multiple times for the same tag if the data size is bigger than the 47 internal buffer size (sizeof(XMLParser.data)). To differentiate between new 48 calls for data you can use the xml*start and xml*end handlers. 49 - It does not handle XML white-space rules for tag data. The raw values 50 including white-space is passed. This is useful in some cases, like for 51 HTML <pre> tags. 52 - The XML specification has no limits on tag and attribute names. For 53 simplicity/sanity sake this XML parser takes some liberties. Tag and 54 attribute names are truncated if they are excessively long. 55 - Entity expansions are not parsed as well as DOCTYPE, ATTLIST etc. 56 57 58 Files used 59 ---------- 60 61 xml.c and xml.h 62 63 64 Interface / API 65 --------------- 66 67 Should be trivial, see xml.c and xml.h and the examples below. 68 69 70 Examples 71 -------- 72 73 See skeleton.c for a base program to start quickly. 74 75 76 License 77 ------- 78 79 ISC, see LICENSE file.