basics.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <html>
  2. <body>
  3. <h1 align='right'><a name='BASICS'><img src="2.gif" align="right"
  4. hspace="10" width="100" height="100" alt="2"></a>Getting Started
  5. with Mini-XML</h1>
  6. <p>This chapter describes how to write programs that use Mini-XML to
  7. access data in an XML file. Mini-XML provides the following
  8. functionality:</p>
  9. <ul>
  10. <li>Functions for creating and managing XML documents
  11. in memory.</li>
  12. <li>Reading of UTF-8 and UTF-16 encoded XML files and
  13. strings.</li>
  14. <li>Writing of UTF-8 encoded XML files and strings.</li>
  15. <li>Support for arbitrary element names, attributes, and
  16. attribute values with no preset limits, just available
  17. memory.</li>
  18. <li>Support for integer, real, opaque ("CDATA"), and text
  19. data types in "leaf" nodes.</li>
  20. <li>"Find", "index", and "walk" functions for easily
  21. accessing data in an XML document.</li>
  22. </ul>
  23. <p>Mini-XML doesn't do validation or other types of processing
  24. on the data based upon schema files or other sources of
  25. definition information, nor does it support character entities
  26. other than those required by the XML specification.</p>
  27. <h2>The Basics</h2>
  28. <p>Mini-XML provides a single header file which you include:</p>
  29. <pre>
  30. #include &lt;mxml.h&gt;
  31. </pre>
  32. <p>The Mini-XML library is included with your program using the
  33. <kbd>-lmxml</kbd> option:</p>
  34. <pre>
  35. <kbd>gcc -o myprogram myprogram.c -lmxml ENTER</kbd>
  36. </pre>
  37. <p>If you have the <tt>pkg-config(1)</tt> software installed,
  38. you can use it to determine the proper compiler and linker options
  39. for your installation:</p>
  40. <pre>
  41. <kbd>pkg-config --cflags mxml ENTER</kbd>
  42. <kbd>pkg-config --libs mxml ENTER</kbd>
  43. </pre>
  44. <h2>Nodes</h2>
  45. <p>Every piece of information in an XML file is stored in memory in "nodes".
  46. Nodes are defined by the <a href='#mxml_node_t'><tt>mxml_node_t</tt></a>
  47. structure. Each node has a typed value, optional user data, a parent node,
  48. sibling nodes (previous and next), and potentially child nodes.</p>
  49. <p>For example, if you have an XML file like the following:</p>
  50. <pre>
  51. &lt;?xml version="1.0" encoding="utf-8"?&gt;
  52. &lt;data&gt;
  53. &lt;node&gt;val1&lt;/node&gt;
  54. &lt;node&gt;val2&lt;/node&gt;
  55. &lt;node&gt;val3&lt;/node&gt;
  56. &lt;group&gt;
  57. &lt;node&gt;val4&lt;/node&gt;
  58. &lt;node&gt;val5&lt;/node&gt;
  59. &lt;node&gt;val6&lt;/node&gt;
  60. &lt;/group&gt;
  61. &lt;node&gt;val7&lt;/node&gt;
  62. &lt;node&gt;val8&lt;/node&gt;
  63. &lt;/data&gt;
  64. </pre>
  65. <p>the node tree for the file would look like the following in memory:</p>
  66. <pre>
  67. ?xml version="1.0" encoding="utf-8"?
  68. |
  69. data
  70. |
  71. node - node - node - group - node - node
  72. | | | | | |
  73. val1 val2 val3 | val7 val8
  74. |
  75. node - node - node
  76. | | |
  77. val4 val5 val6
  78. </pre>
  79. <p>where "-" is a pointer to the sibling node and "|" is a pointer
  80. to the first child or parent node.</p>
  81. <p>The <a href="#mxmlGetType"><tt>mxmlGetType</tt></a> function gets the type of
  82. a node, one of <tt>MXML_CUSTOM</tt>, <tt>MXML_ELEMENT</tt>,
  83. <tt>MXML_INTEGER</tt>, <tt>MXML_OPAQUE</tt>, <tt>MXML_REAL</tt>, or
  84. <tt>MXML_TEXT</tt>. The parent and sibling nodes are accessed using the
  85. <a href="#mxmlGetParent"><tt>mxmlGetParent</tt></a>,
  86. <a href="#mxmlGetNext"><tt>mxmlGetNext</tt></a>, and
  87. <a href="#mxmlGetPrevious"><tt>mxmlGetPrevious</tt></a> functions. The
  88. <a href="#mxmlGetUserData"><tt>mxmlGetUserData</tt></a> function gets any user
  89. data associated with the node.</p>
  90. <h3>CDATA Nodes</h3>
  91. <p>CDATA (<tt>MXML_ELEMENT</tt>) nodes are created using the
  92. <a href="#mxmlNewCDATA"><tt>mxmlNewCDATA</tt></a> function. The
  93. <a href="#mxmlGetCDATA"><tt>mxmlGetCDATA</tt></a> function retrieves the
  94. CDATA string pointer for a node.</p>
  95. <blockquote><b>Note:</b>
  96. <p>CDATA nodes are currently stored in memory as special elements. This will
  97. be changed in a future major release of Mini-XML.</p>
  98. </blockquote>
  99. <h3>Custom Nodes</h3>
  100. <p>Custom (<tt>MXML_CUSTOM</tt>) nodes are created using the
  101. <a href="#mxmlNewCustom"><tt>mxmlNewCustom</tt></a> function or using a custom
  102. load callback specified using the
  103. <a href="#mxmlSetCustomHandlers"><tt>mxmlSetCustomHandlers</tt></a> function.
  104. The <a href="#mxmlGetCustom"><tt>mxmlGetCustom</tt></a> function retrieves the
  105. custom value pointer for a node.</p>
  106. <h3>Comment Nodes</h3>
  107. <p>Comment (<tt>MXML_ELEMENT</tt>) nodes are created using the
  108. <a href="#mxmlNewElement"><tt>mxmlNewElement</tt></a> function. The
  109. <a href="#mxmlGetElement"><tt>mxmlGetElement</tt></a> function retrieves the
  110. comment string pointer for a node, including the surrounding "!--" and "--"
  111. characters.</p>
  112. <blockquote><b>Note:</b>
  113. <p>Comment nodes are currently stored in memory as special elements. This will
  114. be changed in a future major release of Mini-XML.</p>
  115. </blockquote>
  116. <h3>Element Nodes</h3>
  117. <p>Element (<tt>MXML_ELEMENT</tt>) nodes are created using the
  118. <a href="#mxmlNewElement"><tt>mxmlNewElement</tt></a> function. The
  119. <a href="#mxmlGetElement"><tt>mxmlGetElement</tt></a> function retrieves the
  120. element name, the
  121. <a href="#mxmlElementGetAttr"><tt>mxmlElementGetAttr</tt></a> function retrieves
  122. the value string for a named attribute associated with the element, and the
  123. <a href="#mxmlGetFirstChild"><tt>mxmlGetFirstChild</tt></a> and
  124. <a href="#mxmlGetLastChild"><tt>mxmlGetLastChild</tt></a> functions retrieve the
  125. first and last child nodes for the element, respectively.</p>
  126. <h3>Integer Nodes</h3>
  127. <p>Integer (<tt>MXML_INTEGER</tt>) nodes are created using the
  128. <a href="#mxmlNewInteger"><tt>mxmlNewInteger</tt></a> function. The
  129. <a href="#mxmlGetInteger"><tt>mxmlGetInteger</tt></a> function retrieves the
  130. integer value for a node.</p>
  131. <h3>Opaque Nodes</h3>
  132. <p>Opaque (<tt>MXML_OPAQUE</tt>) nodes are created using the
  133. <a href="#mxmlNewOpaque"><tt>mxmlNewOpaque</tt></a> function. The
  134. <a href="#mxmlGetOpaque"><tt>mxmlGetOpaque</tt></a> function retrieves the
  135. opaque string pointer for a node. Opaque nodes are like string nodes but
  136. preserve all whitespace between nodes.</p>
  137. <h3>Text Nodes</h3>
  138. <p>Text (<tt>MXML_TEXT</tt>) nodes are created using the
  139. <a href="#mxmlNewText"><tt>mxmlNewText</tt></a> and
  140. <a href="#mxmlNewTextf"><tt>mxmlNewTextf</tt></a> functions. Each text node
  141. consists of a text string and (leading) whitespace value - the
  142. <a href="#mxmlGetText"><tt>mxmlGetText</tt></a> function retrieves the
  143. text string pointer and whitespace value for a node.</p>
  144. <!-- NEED 12 -->
  145. <h3>Processing Instruction Nodes</h3>
  146. <p>Processing instruction (<tt>MXML_ELEMENT</tt>) nodes are created using the
  147. <a href="#mxmlNewElement"><tt>mxmlNewElement</tt></a> function. The
  148. <a href="#mxmlGetElement"><tt>mxmlGetElement</tt></a> function retrieves the
  149. processing instruction string for a node, including the surrounding "?"
  150. characters.</p>
  151. <blockquote><b>Note:</b>
  152. <p>Processing instruction nodes are currently stored in memory as special
  153. elements. This will be changed in a future major release of Mini-XML.</p>
  154. </blockquote>
  155. <h3>Real Number Nodes</h3>
  156. <p>Real number (<tt>MXML_REAL</tt>) nodes are created using the
  157. <a href="#mxmlNewReal"><tt>mxmlNewReal</tt></a> function. The
  158. <a href="#mxmlGetReal"><tt>mxmlGetReal</tt></a> function retrieves the
  159. CDATA string pointer for a node.</p>
  160. <!-- NEED 15 -->
  161. <h3>XML Declaration Nodes</h3>
  162. <p>XML declaration (<tt>MXML_ELEMENT</tt>) nodes are created using the
  163. <a href="#mxmlNewXML"><tt>mxmlNewXML</tt></a> function. The
  164. <a href="#mxmlGetElement"><tt>mxmlGetElement</tt></a> function retrieves the
  165. XML declaration string for a node, including the surrounding "?" characters.</p>
  166. <blockquote><b>Note:</b>
  167. <p>XML declaration nodes are currently stored in memory as special elements.
  168. This will be changed in a future major release of Mini-XML.</p>
  169. </blockquote>
  170. <!-- NEW PAGE -->
  171. <h2>Creating XML Documents</h2>
  172. <p>You can create and update XML documents in memory using the
  173. various <tt>mxmlNew</tt> functions. The following code will
  174. create the XML document described in the previous section:</p>
  175. <pre>
  176. mxml_node_t *xml; /* &lt;?xml ... ?&gt; */
  177. mxml_node_t *data; /* &lt;data&gt; */
  178. mxml_node_t *node; /* &lt;node&gt; */
  179. mxml_node_t *group; /* &lt;group&gt; */
  180. xml = mxmlNewXML("1.0");
  181. data = mxmlNewElement(xml, "data");
  182. node = mxmlNewElement(data, "node");
  183. mxmlNewText(node, 0, "val1");
  184. node = mxmlNewElement(data, "node");
  185. mxmlNewText(node, 0, "val2");
  186. node = mxmlNewElement(data, "node");
  187. mxmlNewText(node, 0, "val3");
  188. group = mxmlNewElement(data, "group");
  189. node = mxmlNewElement(group, "node");
  190. mxmlNewText(node, 0, "val4");
  191. node = mxmlNewElement(group, "node");
  192. mxmlNewText(node, 0, "val5");
  193. node = mxmlNewElement(group, "node");
  194. mxmlNewText(node, 0, "val6");
  195. node = mxmlNewElement(data, "node");
  196. mxmlNewText(node, 0, "val7");
  197. node = mxmlNewElement(data, "node");
  198. mxmlNewText(node, 0, "val8");
  199. </pre>
  200. <!-- NEED 6 -->
  201. <p>We start by creating the declaration node common to all XML files using the
  202. <a href="#mxmlNewXML"><tt>mxmlNewXML</tt></a> function:</p>
  203. <pre>
  204. xml = mxmlNewXML("1.0");
  205. </pre>
  206. <p>We then create the <tt>&lt;data&gt;</tt> node used for this document using
  207. the <a href="#mxmlNewElement"><tt>mxmlNewElement</tt></a> function. The first
  208. argument specifies the parent node (<tt>xml</tt>) while the second specifies the
  209. element name (<tt>data</tt>):</p>
  210. <pre>
  211. data = mxmlNewElement(xml, "data");
  212. </pre>
  213. <p>Each <tt>&lt;node&gt;...&lt;/node&gt;</tt> in the file is created using the
  214. <tt>mxmlNewElement</tt> and <a href="#mxmlNewText"><tt>mxmlNewText</tt></a>
  215. functions. The first argument of <tt>mxmlNewText</tt> specifies the parent node
  216. (<tt>node</tt>). The second argument specifies whether whitespace appears before
  217. the text - 0 or false in this case. The last argument specifies the actual text
  218. to add:</p>
  219. <pre>
  220. node = mxmlNewElement(data, "node");
  221. mxmlNewText(node, 0, "val1");
  222. </pre>
  223. <p>The resulting in-memory XML document can then be saved or processed just like
  224. one loaded from disk or a string.</p>
  225. <!-- NEED 15 -->
  226. <h2>Loading XML</h2>
  227. <p>You load an XML file using the <a
  228. href='#mxmlLoadFile'><tt>mxmlLoadFile</tt></a>
  229. function:</p>
  230. <pre>
  231. FILE *fp;
  232. mxml_node_t *tree;
  233. fp = fopen("filename.xml", "r");
  234. tree = mxmlLoadFile(NULL, fp,
  235. MXML_TEXT_CALLBACK);
  236. fclose(fp);
  237. </pre>
  238. <p>The first argument specifies an existing XML parent node, if
  239. any. Normally you will pass <tt>NULL</tt> for this argument
  240. unless you are combining multiple XML sources. The XML file must
  241. contain a complete XML document including the <tt>?xml</tt>
  242. element if the parent node is <tt>NULL</tt>.</p>
  243. <p>The second argument specifies the stdio file to read from, as
  244. opened by <tt>fopen()</tt> or <tt>popen()</tt>. You can also use
  245. <tt>stdin</tt> if you are implementing an XML filter
  246. program.</p>
  247. <p>The third argument specifies a callback function which returns
  248. the value type of the immediate children for a new element node:
  249. <tt>MXML_CUSTOM</tt>, <tt>MXML_IGNORE</tt>,
  250. <tt>MXML_INTEGER</tt>, <tt>MXML_OPAQUE</tt>, <tt>MXML_REAL</tt>,
  251. or <tt>MXML_TEXT</tt>. Load callbacks are described in detail in
  252. <a href='#LOAD_CALLBACKS'>Chapter 3</a>. The example code uses
  253. the <tt>MXML_TEXT_CALLBACK</tt> constant which specifies that all
  254. data nodes in the document contain whitespace-separated text
  255. values. Other standard callbacks include
  256. <tt>MXML_IGNORE_CALLBACK</tt>, <tt>MXML_INTEGER_CALLBACK</tt>,
  257. <tt>MXML_OPAQUE_CALLBACK</tt>, and
  258. <tt>MXML_REAL_CALLBACK</tt>.</p>
  259. <p>The <a href='#mxmlLoadString'><tt>mxmlLoadString</tt></a>
  260. function loads XML node trees from a string:</p>
  261. <!-- NEED 10 -->
  262. <pre>
  263. char buffer[8192];
  264. mxml_node_t *tree;
  265. ...
  266. tree = mxmlLoadString(NULL, buffer,
  267. MXML_TEXT_CALLBACK);
  268. </pre>
  269. <p>The first and third arguments are the same as used for
  270. <tt>mxmlLoadFile()</tt>. The second argument specifies the
  271. string or character buffer to load and must be a complete XML
  272. document including the <tt>?xml</tt> element if the parent node
  273. is <tt>NULL</tt>.</p>
  274. <!-- NEED 15 -->
  275. <h2>Saving XML</h2>
  276. <p>You save an XML file using the <a
  277. href='#mxmlSaveFile'><tt>mxmlSaveFile</tt></a> function:</p>
  278. <pre>
  279. FILE *fp;
  280. mxml_node_t *tree;
  281. fp = fopen("filename.xml", "w");
  282. mxmlSaveFile(tree, fp, MXML_NO_CALLBACK);
  283. fclose(fp);
  284. </pre>
  285. <p>The first argument is the XML node tree to save. It should
  286. normally be a pointer to the top-level <tt>?xml</tt> node in
  287. your XML document.</p>
  288. <p>The second argument is the stdio file to write to, as opened
  289. by <tt>fopen()</tt> or <tt>popen()</tt>. You can also use
  290. <tt>stdout</tt> if you are implementing an XML filter
  291. program.</p>
  292. <p>The third argument is the whitespace callback to use when
  293. saving the file. Whitespace callbacks are covered in detail in <a
  294. href='SAVE_CALLBACKS'>Chapter 3</a>. The previous example code
  295. uses the <tt>MXML_NO_CALLBACK</tt> constant to specify that no
  296. special whitespace handling is required.</p>
  297. <p>The <a
  298. href='#mxmlSaveAllocString'><tt>mxmlSaveAllocString</tt></a>,
  299. and <a href='#mxmlSaveString'><tt>mxmlSaveString</tt></a>
  300. functions save XML node trees to strings:</p>
  301. <pre>
  302. char buffer[8192];
  303. char *ptr;
  304. mxml_node_t *tree;
  305. ...
  306. mxmlSaveString(tree, buffer, sizeof(buffer),
  307. MXML_NO_CALLBACK);
  308. ...
  309. ptr = mxmlSaveAllocString(tree, MXML_NO_CALLBACK);
  310. </pre>
  311. <p>The first and last arguments are the same as used for
  312. <tt>mxmlSaveFile()</tt>. The <tt>mxmlSaveString</tt> function
  313. takes pointer and size arguments for saving the XML document to
  314. a fixed-size buffer, while <tt>mxmlSaveAllocString()</tt>
  315. returns a string buffer that was allocated using
  316. <tt>malloc()</tt>.</p>
  317. <!-- NEED 15 -->
  318. <h3>Controlling Line Wrapping</h3>
  319. <p>When saving XML documents, Mini-XML normally wraps output
  320. lines at column 75 so that the text is readable in terminal
  321. windows. The <a
  322. href='#mxmlSetWrapMargin'><tt>mxmlSetWrapMargin</tt></a> function
  323. overrides the default wrap margin:</p>
  324. <pre>
  325. /* Set the margin to 132 columns */
  326. mxmlSetWrapMargin(132);
  327. /* Disable wrapping */
  328. mxmlSetWrapMargin(0);
  329. </pre>
  330. <h2>Memory Management</h2>
  331. <p>Once you are done with the XML data, use the <a
  332. href="#mxmlDelete"><tt>mxmlDelete</tt></a> function to recursively
  333. free the memory that is used for a particular node or the entire
  334. tree:</p>
  335. <pre>
  336. mxmlDelete(tree);
  337. </pre>
  338. <p>You can also use reference counting to manage memory usage. The
  339. <a href="#mxmlRetain"><tt>mxmlRetain</tt></a> and
  340. <a href="#mxmlRelease"><tt>mxmlRelease</tt></a> functions increment and
  341. decrement a node's use count, respectively. When the use count goes to 0,
  342. <tt>mxmlRelease</tt> will automatically call <tt>mxmlDelete</tt> to actually
  343. free the memory used by the node tree. New nodes automatically start with a
  344. use count of 1.</p>
  345. <!-- NEW PAGE-->
  346. <h2>Finding and Iterating Nodes</h2>
  347. <p>The <a
  348. href='#mxmlWalkPrev'><tt>mxmlWalkPrev</tt></a>
  349. and <a
  350. href='#mxmlWalkNext'><tt>mxmlWalkNext</tt></a>functions
  351. can be used to iterate through the XML node tree:</p>
  352. <pre>
  353. mxml_node_t *node;
  354. node = mxmlWalkPrev(current, tree,
  355. MXML_DESCEND);
  356. node = mxmlWalkNext(current, tree,
  357. MXML_DESCEND);
  358. </pre>
  359. <p>In addition, you can find a named element/node using the <a
  360. href='#mxmlFindElement'><tt>mxmlFindElement</tt></a>
  361. function:</p>
  362. <pre>
  363. mxml_node_t *node;
  364. node = mxmlFindElement(tree, tree, "name",
  365. "attr", "value",
  366. MXML_DESCEND);
  367. </pre>
  368. <p>The <tt>name</tt>, <tt>attr</tt>, and <tt>value</tt>
  369. arguments can be passed as <tt>NULL</tt> to act as wildcards,
  370. e.g.:</p>
  371. <!-- NEED 4 -->
  372. <pre>
  373. /* Find the first "a" element */
  374. node = mxmlFindElement(tree, tree, "a",
  375. NULL, NULL,
  376. MXML_DESCEND);
  377. </pre>
  378. <!-- NEED 5 -->
  379. <pre>
  380. /* Find the first "a" element with "href"
  381. attribute */
  382. node = mxmlFindElement(tree, tree, "a",
  383. "href", NULL,
  384. MXML_DESCEND);
  385. </pre>
  386. <!-- NEED 6 -->
  387. <pre>
  388. /* Find the first "a" element with "href"
  389. to a URL */
  390. node = mxmlFindElement(tree, tree, "a",
  391. "href",
  392. "http://www.easysw.com/",
  393. MXML_DESCEND);
  394. </pre>
  395. <!-- NEED 5 -->
  396. <pre>
  397. /* Find the first element with a "src"
  398. attribute */
  399. node = mxmlFindElement(tree, tree, NULL,
  400. "src", NULL,
  401. MXML_DESCEND);
  402. </pre>
  403. <!-- NEED 5 -->
  404. <pre>
  405. /* Find the first element with a "src"
  406. = "foo.jpg" */
  407. node = mxmlFindElement(tree, tree, NULL,
  408. "src", "foo.jpg",
  409. MXML_DESCEND);
  410. </pre>
  411. <p>You can also iterate with the same function:</p>
  412. <pre>
  413. mxml_node_t *node;
  414. for (node = mxmlFindElement(tree, tree,
  415. "name",
  416. NULL, NULL,
  417. MXML_DESCEND);
  418. node != NULL;
  419. node = mxmlFindElement(node, tree,
  420. "name",
  421. NULL, NULL,
  422. MXML_DESCEND))
  423. {
  424. ... do something ...
  425. }
  426. </pre>
  427. <!-- NEED 10 -->
  428. <p>The <tt>MXML_DESCEND</tt> argument can actually be one of
  429. three constants:</p>
  430. <ul>
  431. <li><tt>MXML_NO_DESCEND</tt> means to not to look at any
  432. child nodes in the element hierarchy, just look at
  433. siblings at the same level or parent nodes until the top
  434. node or top-of-tree is reached.
  435. <p>The previous node from "group" would be the "node"
  436. element to the left, while the next node from "group" would
  437. be the "node" element to the right.<br><br></p></li>
  438. <li><tt>MXML_DESCEND_FIRST</tt> means that it is OK to
  439. descend to the first child of a node, but not to descend
  440. further when searching. You'll normally use this when
  441. iterating through direct children of a parent node, e.g. all
  442. of the "node" and "group" elements under the "?xml" parent
  443. node in the example above.
  444. <p>This mode is only applicable to the search function; the
  445. walk functions treat this as <tt>MXML_DESCEND</tt> since
  446. every call is a first time.<br><br></p></li>
  447. <li><tt>MXML_DESCEND</tt> means to keep descending until
  448. you hit the bottom of the tree. The previous node from
  449. "group" would be the "val3" node and the next node would
  450. be the first node element under "group".
  451. <p>If you were to walk from the root node "?xml" to the end
  452. of the tree with <tt>mxmlWalkNext()</tt>, the order would
  453. be:</p>
  454. <p><tt>?xml data node val1 node val2 node val3 group node
  455. val4 node val5 node val6 node val7 node val8</tt></p>
  456. <p>If you started at "val8" and walked using
  457. <tt>mxmlWalkPrev()</tt>, the order would be reversed,
  458. ending at "?xml".</p></li>
  459. </ul>
  460. <h2>Finding Specific Nodes</h2>
  461. <p>You can find specific nodes in the tree using the <a
  462. href='#mxmlFindValue'><tt>mxmlFindPath</tt></a>, for example:
  463. <pre>
  464. mxml_node_t *value;
  465. value = mxmlFindPath(tree, "path/to/*/foo/bar");
  466. </pre>
  467. <p>The second argument is a "path" to the parent node. Each component of the
  468. path is separated by a slash (/) and represents a named element in the document
  469. tree or a wildcard (*) path representing 0 or more intervening nodes.</p>
  470. </body>
  471. </html>