1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head><title>ezXML</title></head>
6 <h1>ezXML - XML Parsing C Library</h1>
9 ezXML is a C library for parsing XML documents inspired by
10 <a href="http://www.php.net/SimpleXML">simpleXML</a> for
11 PHP. As the name implies, it's easy to use. It's ideal for parsing xml
12 configuration files or REST web service responses. It's also fast and
13 lightweight (11k compiled). The latest version is available here:
14 <a href="http://prdownloads.sf.net/ezxml/ezxml-0.8.tar.gz?download"
20 Given the following example xml document:
23 <?xml version="1.0"?><br />
24 <formula1><br />
25 <team name="McLaren"><br />
26 <driver><br />
27 <name>Kimi
28 Raikkonen</name><br />
29 <points>45</points><br />
30 </driver><br />
31 <driver><br />
32 <name>David
33 Coultard</name><br />
34 <points>24</points><br />
35 </driver><br />
36 </team><br />
40 This code snipped prints out a list of drivers, which team they drive for,
41 and how many championship points they have:
44 ezxml_t f1 = ezxml_parse_file("formula1.xml"), team, driver;<br />
45 const char *teamname;<br />
47 for (team = ezxml_child(f1, "team"); team; team = team->next) {<br />
48 teamname = ezxml_attr(team, "name");<br />
49 for (driver = ezxml_child(team, "driver"); driver;
50 driver = driver->next) {<br />
51 printf("%s, %s: %s\n",
52 ezxml_child(driver, "name")->txt, teamname,<br />
53
54 ezxml_child(driver, "points")->txt);<br />
55 }<br />
60 Alternately, the following would print out the name of the second driver
64 ezxml_t f1 = ezxml_parse_file("formula1.xml");<br />
66 printf("%s\n", ezxml_get(f1, "team", 0, "driver", 1, "name", -1)->txt);
70 The -1 indicates the end of the argument list. That's pretty much all
71 there is to it. Complete API documentation can be found in ezxml.h.
74 <b>Known Limitations</b>
77 No support for UTF-16, however UTF-8 is handled correctly. UTF-16
78 support is required for XML 1.0 conformity and will be implimented for
83 Loads the entire xml document into memory at once and does not allow for
84 documents to be passed in a chunk at a time. Large xml files can still
85 be handled though through <code>ezxml_parse_file()</code> and
86 <code>ezxml_parse_fd()</code>, which use mmap to map the file to a
87 virtual address space and rely on the virtual memory system to page in
92 Ignores DTDs. Parsing of the internal DTD subset is required for XML 1.0
93 conformity and will be implimented for the 1.0 release. ezXML is not,
94 and is not likely to become, a validating parser.
98 In making the character content of tags easy to access, there is no
99 way provided to keep track of the location of sub tags relative to the
100 character data. Example:
102 <code><doc>line one<br/><br />line two</doc></code>
105 The character content of the doc tag is reported as
106 <code>"line one\nline two"</code>, and <code><br/></code> is
107 reported as a sub tag, but the location of <code><br/></code>
108 within the character data is not. The function
109 <code>ezxml_toxml()</code> will convert an ezXML structure back to xml
110 with sub tag locations intact.
117 ezXML was written by Aaron Voisine and is distributed under the terms of
118 the <a href="license.txt">MIT license</a>.