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 (less than 20k compiled). The latest version is available
15 <a href="http://prdownloads.sf.net/ezxml/ezxml-0.8.5.tar.gz?download"
16 >ezxml-0.8.5.tar.gz</a>
21 Given the following example XML document:
24 <?xml version="1.0"?><br />
25 <formula1><br />
26 <team name="McLaren"><br />
27 <driver><br />
28 <name>Kimi
29 Raikkonen</name><br />
30 <points>45</points><br />
31 </driver><br />
32 <driver><br />
33 <name>David
34 Coultard</name><br />
35 <points>24</points><br />
36 </driver><br />
37 </team><br />
41 This code snippet prints out a list of drivers, which team they drive for,
42 and how many championship points they have:
45 ezxml_t f1 = ezxml_parse_file("formula1.xml"), team, driver;<br />
46 const char *teamname;<br />
48 for (team = ezxml_child(f1, "team"); team; team = team->next) {<br />
49 teamname = ezxml_attr(team, "name");<br />
50 for (driver = ezxml_child(team, "driver"); driver;
51 driver = driver->next) {<br />
52 printf("%s, %s: %s\n",
53 ezxml_child(driver, "name")->txt, teamname,<br />
54
55 ezxml_child(driver, "points")->txt);<br />
56 }<br />
61 Alternately, the following would print out the name of the second driver
65 ezxml_t f1 = ezxml_parse_file("formula1.xml");<br />
67 printf("%s\n", ezxml_get(f1, "team", 0, "driver", 1, "name", -1)->txt);
71 The -1 indicates the end of the argument list. That's pretty much all
72 there is to it. Complete API documentation can be found in ezxml.h.
75 <b>Known Limitations</b>
78 ezXML is not a validating parser.
82 Loads the entire XML document into memory at once and does not allow for
83 documents to be passed in a chunk at a time. Large XML files can still
84 be handled though through <code>ezxml_parse_file()</code> and
85 <code>ezxml_parse_fd()</code>, which use mmap to map the file to a
86 virtual address space and rely on the virtual memory system to page in
91 Does not currently recognize all possible well-formedness errors. It
92 should correctly handle all well-formed XML documents and will either
93 ignore or halt XML processing on well-formedness errors. More
94 well-formedness checking will be added in subsiquent releases.
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>.