libxml-ruby 0.8.3-x86-mswin32-60 → 0.9.0-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. data/CHANGES +18 -0
  2. data/RAKEFILE +15 -39
  3. data/README +48 -47
  4. data/ext/libxml/libxml.c +847 -22
  5. data/ext/libxml/ruby_libxml.h +71 -95
  6. data/ext/libxml/ruby_xml_attr.c +500 -500
  7. data/ext/libxml/ruby_xml_attributes.c +1 -1
  8. data/ext/libxml/ruby_xml_document.c +1144 -1135
  9. data/ext/libxml/ruby_xml_document.h +4 -11
  10. data/ext/libxml/ruby_xml_dtd.c +27 -0
  11. data/ext/libxml/ruby_xml_encoding.c +164 -0
  12. data/ext/libxml/ruby_xml_encoding.h +13 -0
  13. data/ext/libxml/ruby_xml_error.c +941 -0
  14. data/ext/libxml/ruby_xml_error.h +13 -0
  15. data/ext/libxml/ruby_xml_html_parser.c +71 -387
  16. data/ext/libxml/ruby_xml_html_parser.h +1 -17
  17. data/ext/libxml/ruby_xml_input.c +179 -0
  18. data/ext/libxml/ruby_xml_input.h +18 -0
  19. data/ext/libxml/ruby_xml_input_cbg.c +17 -3
  20. data/ext/libxml/ruby_xml_node.c +1566 -1582
  21. data/ext/libxml/ruby_xml_node.h +1 -4
  22. data/ext/libxml/ruby_xml_ns.c +14 -3
  23. data/ext/libxml/ruby_xml_parser.c +164 -1398
  24. data/ext/libxml/ruby_xml_parser.h +5 -17
  25. data/ext/libxml/ruby_xml_parser_context.c +131 -169
  26. data/ext/libxml/ruby_xml_parser_context.h +2 -9
  27. data/ext/libxml/ruby_xml_reader.c +910 -945
  28. data/ext/libxml/ruby_xml_relaxng.c +32 -3
  29. data/ext/libxml/ruby_xml_sax_parser.c +106 -364
  30. data/ext/libxml/ruby_xml_sax_parser.h +1 -37
  31. data/ext/libxml/ruby_xml_schema.c +174 -145
  32. data/ext/libxml/ruby_xml_xinclude.c +9 -5
  33. data/ext/libxml/ruby_xml_xpath.c +25 -6
  34. data/ext/libxml/ruby_xml_xpath.h +1 -2
  35. data/ext/libxml/ruby_xml_xpath_context.c +17 -19
  36. data/ext/libxml/ruby_xml_xpath_object.c +60 -56
  37. data/ext/libxml/ruby_xml_xpointer.c +11 -5
  38. data/ext/libxml/sax_parser_callbacks.inc +42 -37
  39. data/ext/libxml/version.h +3 -3
  40. data/ext/mingw/Rakefile +20 -27
  41. data/ext/mingw/build.rake +41 -0
  42. data/{lib → ext/mingw}/libiconv-2.dll +0 -0
  43. data/ext/mingw/libxml2-2.dll +0 -0
  44. data/ext/mingw/libxml_ruby.dll.a +0 -0
  45. data/ext/mingw/libxml_ruby.so +0 -0
  46. data/ext/vc/libxml_ruby.vcproj +23 -15
  47. data/lib/libxml.rb +8 -2
  48. data/lib/libxml/document.rb +16 -4
  49. data/lib/libxml/error.rb +84 -0
  50. data/lib/libxml/hpricot.rb +76 -0
  51. data/lib/libxml/html_parser.rb +61 -0
  52. data/lib/libxml/node.rb +36 -25
  53. data/lib/libxml/parser.rb +312 -33
  54. data/lib/libxml/parser_context.rb +17 -0
  55. data/lib/libxml/properties.rb +15 -2
  56. data/lib/libxml/reader.rb +15 -0
  57. data/lib/libxml/sax_callbacks.rb +179 -0
  58. data/lib/libxml/sax_parser.rb +42 -0
  59. data/lib/libxml/tree.rb +1 -2
  60. data/lib/libxml/xpath_object.rb +12 -0
  61. data/test/model/atom.xml +4 -0
  62. data/test/tc_attributes.rb +43 -19
  63. data/test/tc_document.rb +1 -1
  64. data/test/tc_document_write.rb +15 -8
  65. data/test/tc_dtd.rb +36 -20
  66. data/test/tc_encoding.rb +13 -0
  67. data/test/tc_error.rb +136 -0
  68. data/test/tc_node.rb +2 -3
  69. data/test/tc_node_copy.rb +1 -1
  70. data/test/tc_node_edit.rb +6 -0
  71. data/test/tc_ns.rb +18 -0
  72. data/test/tc_parser.rb +113 -228
  73. data/test/tc_parser_context.rb +1 -2
  74. data/test/tc_reader.rb +24 -14
  75. data/test/tc_relaxng.rb +18 -6
  76. data/test/tc_sax_parser.rb +48 -13
  77. data/test/tc_schema.rb +20 -8
  78. data/test/tc_well_formed.rb +2 -1
  79. data/test/tc_xml.rb +212 -0
  80. data/test/tc_xpath.rb +60 -46
  81. data/test/tc_xpointer.rb +7 -11
  82. data/test/test_suite.rb +4 -3
  83. metadata +32 -115
  84. data/doc/rdoc/classes/LibXML.html +0 -241
  85. data/doc/rdoc/classes/LibXML/XML.html +0 -185
  86. data/doc/rdoc/classes/LibXML/XML/Attr.html +0 -1010
  87. data/doc/rdoc/classes/LibXML/XML/Attributes.html +0 -526
  88. data/doc/rdoc/classes/LibXML/XML/Document.html +0 -1489
  89. data/doc/rdoc/classes/LibXML/XML/Dtd.html +0 -213
  90. data/doc/rdoc/classes/LibXML/XML/Error.html +0 -117
  91. data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +0 -348
  92. data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +0 -160
  93. data/doc/rdoc/classes/LibXML/XML/NS.html +0 -381
  94. data/doc/rdoc/classes/LibXML/XML/Node.html +0 -3396
  95. data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +0 -123
  96. data/doc/rdoc/classes/LibXML/XML/Node/Set.html +0 -440
  97. data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +0 -123
  98. data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +0 -123
  99. data/doc/rdoc/classes/LibXML/XML/Parser.html +0 -2239
  100. data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +0 -1255
  101. data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +0 -123
  102. data/doc/rdoc/classes/LibXML/XML/Reader.html +0 -2264
  103. data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +0 -237
  104. data/doc/rdoc/classes/LibXML/XML/SaxParser.html +0 -415
  105. data/doc/rdoc/classes/LibXML/XML/Schema.html +0 -308
  106. data/doc/rdoc/classes/LibXML/XML/State.html +0 -124
  107. data/doc/rdoc/classes/LibXML/XML/Tree.html +0 -111
  108. data/doc/rdoc/classes/LibXML/XML/XInclude.html +0 -123
  109. data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +0 -117
  110. data/doc/rdoc/classes/LibXML/XML/XMLParserOptions.html +0 -198
  111. data/doc/rdoc/classes/LibXML/XML/XPath.html +0 -184
  112. data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +0 -404
  113. data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +0 -172
  114. data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +0 -627
  115. data/doc/rdoc/classes/LibXML/XML/XPointer.html +0 -170
  116. data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +0 -123
  117. data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +0 -117
  118. data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +0 -124
  119. data/doc/rdoc/classes/singleton.html +0 -114
  120. data/doc/rdoc/created.rid +0 -1
  121. data/doc/rdoc/files/CHANGES.html +0 -442
  122. data/doc/rdoc/files/LICENSE.html +0 -133
  123. data/doc/rdoc/files/README.html +0 -388
  124. data/doc/rdoc/files/VERSION.html +0 -107
  125. data/doc/rdoc/files/ext/libxml/cbg_c.html +0 -101
  126. data/doc/rdoc/files/ext/libxml/libxml_c.html +0 -101
  127. data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +0 -101
  128. data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +0 -101
  129. data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +0 -101
  130. data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +0 -101
  131. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +0 -101
  132. data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +0 -101
  133. data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +0 -101
  134. data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +0 -101
  135. data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +0 -101
  136. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +0 -101
  137. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +0 -101
  138. data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +0 -101
  139. data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +0 -101
  140. data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +0 -101
  141. data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +0 -101
  142. data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +0 -101
  143. data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +0 -101
  144. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +0 -101
  145. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +0 -101
  146. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +0 -101
  147. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +0 -101
  148. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +0 -101
  149. data/doc/rdoc/files/lib/libxml/attr_rb.html +0 -108
  150. data/doc/rdoc/files/lib/libxml/attributes_rb.html +0 -108
  151. data/doc/rdoc/files/lib/libxml/document_rb.html +0 -108
  152. data/doc/rdoc/files/lib/libxml/node_rb.html +0 -108
  153. data/doc/rdoc/files/lib/libxml/node_set_rb.html +0 -108
  154. data/doc/rdoc/files/lib/libxml/parser_options_rb.html +0 -107
  155. data/doc/rdoc/files/lib/libxml/parser_rb.html +0 -101
  156. data/doc/rdoc/files/lib/libxml/properties_rb.html +0 -108
  157. data/doc/rdoc/files/lib/libxml/tree_rb.html +0 -107
  158. data/doc/rdoc/files/lib/libxml_rb.html +0 -124
  159. data/doc/rdoc/files/lib/xml/libxml_rb.html +0 -124
  160. data/doc/rdoc/files/lib/xml_rb.html +0 -134
  161. data/doc/rdoc/fr_class_index.html +0 -62
  162. data/doc/rdoc/fr_file_index.html +0 -66
  163. data/doc/rdoc/fr_method_index.html +0 -392
  164. data/doc/rdoc/index.html +0 -24
  165. data/doc/rdoc/rdoc-style.css +0 -208
  166. data/ext/libxml/ruby_xml_node_set.c +0 -172
  167. data/ext/libxml/ruby_xml_node_set.h +0 -20
  168. data/ext/libxml/ruby_xml_xpointer_context.c +0 -22
  169. data/ext/libxml/ruby_xml_xpointer_context.h +0 -18
  170. data/lib/libxml/node_set.rb +0 -27
  171. data/lib/libxml2-2.dll +0 -0
  172. data/lib/libxml_ruby.dll.a +0 -0
  173. data/lib/libxml_ruby.so +0 -0
  174. data/test/tc_node_set.rb +0 -24
  175. data/test/tc_node_set2.rb +0 -37
@@ -1,133 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: LICENSE</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>LICENSE</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>LICENSE
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Fri Jul 18 21:38:00 -0600 2008</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <p>
73
- <a href="../classes/LibXML.html">LibXML</a>-Ruby
74
- </p>
75
- <pre>
76
- Copyright (c) 2002-2006 Sean Chittenden &lt;sean@chittenden.org&gt; and contributors
77
- Copyright (c) 2001 Wai-Sun &quot;Squidster&quot; Chia &lt;waisun.chia@compaq.com&gt;
78
- </pre>
79
- <p>
80
- Permission is hereby granted, free of charge, to any person obtaining a
81
- copy of this software and associated documentation files (the
82
- &quot;Software&quot;), to deal in the Software without restriction,
83
- including without limitation the rights to use, copy, modify, merge,
84
- publish, distribute, sublicense, and/or sell copies of the Software, and to
85
- permit persons to whom the Software is furnished to do so, subject to the
86
- following conditions:
87
- </p>
88
- <p>
89
- The above copyright notice and this permission notice shall be included in
90
- all copies or substantial portions of the Software.
91
- </p>
92
- <p>
93
- THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
94
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
95
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
96
- NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
97
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
98
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
99
- USE OR OTHER DEALINGS IN THE SOFTWARE.
100
- </p>
101
-
102
- </div>
103
-
104
-
105
- </div>
106
-
107
-
108
- </div>
109
-
110
-
111
- <!-- if includes -->
112
-
113
- <div id="section">
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
- <!-- if method_list -->
123
-
124
-
125
- </div>
126
-
127
-
128
- <div id="validator-badges">
129
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
130
- </div>
131
-
132
- </body>
133
- </html>
@@ -1,388 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: README</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>README</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>README
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Mon Jul 21 20:37:43 -0600 2008</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h1><a href="../classes/LibXML.html">LibXML</a> Ruby</h1>
73
- <h2>Overview</h2>
74
- <p>
75
- The libxml gem provides Ruby language bindings for GNOME&#8216;s Libxml2
76
- XML toolkit. It is free software, released under the MIT License.
77
- </p>
78
- <p>
79
- libxml-ruby provides several advantages over REXML:
80
- </p>
81
- <ul>
82
- <li>Speed - libxml is many times faster than REXML
83
-
84
- </li>
85
- <li>Features - libxml provides a number of additional features over REXML,
86
- including XML Schema Validation, RelaxNg validation, xslt (see
87
- libxslt-ruby)
88
-
89
- </li>
90
- <li>Conformance - libxml passes all 1800+ tests from the OASIS XML Tests Suite
91
-
92
- </li>
93
- </ul>
94
- <h2>Requirements</h2>
95
- <p>
96
- libxml-ruby requires Ruby 1.8.4 or higher. It is dependent on the following
97
- libraries to function properly:
98
- </p>
99
- <ul>
100
- <li>libm (math routines: very standard)
101
-
102
- </li>
103
- <li>libz (zlib)
104
-
105
- </li>
106
- <li>libiconv
107
-
108
- </li>
109
- <li>libxml2
110
-
111
- </li>
112
- </ul>
113
- <p>
114
- If you are running Linux or Unix you&#8216;ll need a C compiler so the
115
- extension can be compiled when it is installed. If you are running Windows,
116
- then install the Windows specific RubyGem which includes an already built
117
- extension.
118
- </p>
119
- <h2>INSTALLATION</h2>
120
- <p>
121
- The easiest way to install libxml-ruby is via Ruby Gems. To install:
122
- </p>
123
- <p>
124
- <tt>gem install libxml-ruby</tt>
125
- </p>
126
- <p>
127
- If you are running Windows, make sure to install the Win32 RubyGem which
128
- includes an already built binary file. The binary is built against libxml2
129
- version 2.6.32 and iconv version 1.11. Both of these are also included as
130
- pre-built binaries, and should be put either in the libxml/lib directory or
131
- on the Windows path.
132
- </p>
133
- <p>
134
- The Windows binaries are built with MingW and include libxml-ruby, libxml2
135
- and iconv. The gem also includes a Microsoft VC++ 2008 solution. If you
136
- wish to run a debug version of libxml-ruby on Windows, then it is highly
137
- recommended you use VC++.
138
- </p>
139
- <h2>Functionality</h2>
140
- <p>
141
- libxml is a highly conformant XML parser, passing all 1800+ tests from the
142
- OASIS XML Tests Suite. In addition, it includes rich functionality such as:
143
- </p>
144
- <ul>
145
- <li>SAX
146
-
147
- </li>
148
- <li>DOM
149
-
150
- </li>
151
- <li>HTML Parsing
152
-
153
- </li>
154
- <li>XMLReader
155
-
156
- </li>
157
- <li>XPath
158
-
159
- </li>
160
- <li>XPointer
161
-
162
- </li>
163
- <li>DTDs
164
-
165
- </li>
166
- <li>RelaxNG Schemas
167
-
168
- </li>
169
- <li>XML Schema
170
-
171
- </li>
172
- <li>XSLT (split into the libxslt-ruby bindings)
173
-
174
- </li>
175
- </ul>
176
- <p>
177
- libxml-ruby provides impressive coverage of libxml&#8216;s functionality
178
- through an easy-to-use C api.
179
- </p>
180
- <h2>Performance</h2>
181
- <p>
182
- In addition to being feature rich and conformation, the main reason people
183
- use libxml-ruby is for performance. Here are the results of a couple simple
184
- benchmarks recently blogged about on the Web (you can find them in the
185
- benchmark directory of the libxml distribution).
186
- </p>
187
- <p>
188
- From <a
189
- href="http://depixelate.com/2008/4/23/ruby-xml-parsing-benchmarks">depixelate.com/2008/4/23/ruby-xml-parsing-benchmarks</a>
190
- </p>
191
- <pre>
192
- user system total real
193
- libxml 0.032000 0.000000 0.032000 ( 0.031000)
194
- Hpricot 0.640000 0.031000 0.671000 ( 0.890000)
195
- REXML 1.813000 0.047000 1.860000 ( 2.031000)
196
- </pre>
197
- <p>
198
- From <a
199
- href="https://svn.concord.org/svn/projects/trunk/common/ruby/xml_benchmarks">svn.concord.org/svn/projects/trunk/common/ruby/xml_benchmarks</a>/
200
- </p>
201
- <pre>
202
- user system total real
203
- libxml 0.641000 0.031000 0.672000 ( 0.672000)
204
- hpricot 5.359000 0.062000 5.421000 ( 5.516000)
205
- rexml 22.859000 0.047000 22.906000 ( 23.203000)
206
- </pre>
207
- <h2>USAGE</h2>
208
- <p>
209
- For in-depth information about using libxml-ruby please refer to its online
210
- Rdoc documentation.
211
- </p>
212
- <p>
213
- All libxml classes are in the <a
214
- href="../classes/LibXML/XML.html">LibXML::XML</a> module. The simplest way
215
- to use libxml is to require &#8216;xml&#8217;. This will mixin the <a
216
- href="../classes/LibXML.html">LibXML</a> module into the global namespace,
217
- allowing you to write code like this:
218
- </p>
219
- <p>
220
- require &#8216;xml&#8217; document = XML::Document.new
221
- </p>
222
- <p>
223
- If you prefer not to add the <a href="../classes/LibXML.html">LibXML</a>
224
- module to the global namepace, then write your code like this:
225
- </p>
226
- <p>
227
- require &#8216;libxml&#8216;
228
- </p>
229
- <p>
230
- class MyClass
231
- </p>
232
- <pre>
233
- def some_method
234
- document = LibXML::XML::Document.new
235
- end
236
- </pre>
237
- <p>
238
- end
239
- </p>
240
- <p>
241
- Some simple examples are shown below.
242
- </p>
243
- <h3>READING</h3>
244
- <p>
245
- There are several ways to read xml documents.
246
- </p>
247
- <pre>
248
- require 'xml'
249
- doc = XML::Document.file('output.xml')
250
- root = doc.root
251
-
252
- puts &quot;Root element name: #{root.name}&quot;
253
-
254
- elem3 = root.find('elem3').to_a.first
255
- puts &quot;Elem3: #{elem3['attr']}&quot;
256
-
257
- doc.find('//root_node/foo/bar').each do |node|
258
- puts &quot;Node path: #{node.path} \t Contents: #{node.content}&quot;
259
- end
260
- </pre>
261
- <p>
262
- And your terminal should look like:
263
- </p>
264
- <pre>
265
- Root element name: root_node
266
- Elem3: baz
267
- Node path: /root_node/foo/bar[1] Contents: 1
268
- Node path: /root_node/foo/bar[2] Contents: 2
269
- Node path: /root_node/foo/bar[3] Contents: 3
270
- Node path: /root_node/foo/bar[4] Contents: 4
271
- Node path: /root_node/foo/bar[5] Contents: 5
272
- Node path: /root_node/foo/bar[6] Contents: 6
273
- Node path: /root_node/foo/bar[7] Contents: 7
274
- Node path: /root_node/foo/bar[8] Contents: 8
275
- Node path: /root_node/foo/bar[9] Contents: 9
276
- Node path: /root_node/foo/bar[10] Contents: 10
277
- </pre>
278
- <h3>WRITING</h3>
279
- <p>
280
- To write a simple document:
281
- </p>
282
- <pre>
283
- require 'xml'
284
-
285
- doc = XML::Document.new()
286
- doc.root = XML::Node.new('root_node')
287
- root = doc.root
288
-
289
- root &lt;&lt; elem1 = XML::Node.new('elem1')
290
- elem1['attr1'] = 'val1'
291
- elem1['attr2'] = 'val2'
292
-
293
- root &lt;&lt; elem2 = XML::Node.new('elem2')
294
- elem2['attr1'] = 'val1'
295
- elem2['attr2'] = 'val2'
296
-
297
- root &lt;&lt; elem3 = XML::Node.new('elem3')
298
- elem3 &lt;&lt; elem4 = XML::Node.new('elem4')
299
- elem3 &lt;&lt; elem5 = XML::Node.new('elem5')
300
-
301
- elem5 &lt;&lt; elem6 = XML::Node.new('elem6')
302
- elem6 &lt;&lt; 'Content for element 6'
303
-
304
- elem3['attr'] = 'baz'
305
-
306
- format = true
307
- doc.save('output.xml', format)
308
- </pre>
309
- <p>
310
- The file output.xml contains:
311
- </p>
312
- <pre>
313
- &lt;?xml version=&quot;1.0&quot;?&gt;
314
- &lt;root_node&gt;
315
- &lt;elem1 attr1=&quot;val1&quot; attr2=&quot;val2&quot;/&gt;
316
- &lt;elem2 attr1=&quot;val1&quot; attr2=&quot;val2&quot;/&gt;
317
- &lt;elem3 attr=&quot;baz&quot;&gt;
318
- &lt;elem4/&gt;
319
- &lt;elem5&gt;
320
- &lt;elem6&gt;Content for element 6&lt;/elem6&gt;
321
- &lt;/elem5&gt;
322
- &lt;/elem3&gt;
323
- &lt;foo&gt;
324
- &lt;bar&gt;1&lt;/bar&gt;
325
- &lt;bar&gt;2&lt;/bar&gt;
326
- &lt;bar&gt;3&lt;/bar&gt;
327
- &lt;bar&gt;4&lt;/bar&gt;
328
- &lt;bar&gt;5&lt;/bar&gt;
329
- &lt;bar&gt;6&lt;/bar&gt;
330
- &lt;bar&gt;7&lt;/bar&gt;
331
- &lt;bar&gt;8&lt;/bar&gt;
332
- &lt;bar&gt;9&lt;/bar&gt;
333
- &lt;bar&gt;10&lt;/bar&gt;
334
- &lt;/foo&gt;
335
- &lt;/root_node&gt;
336
- </pre>
337
- <h2>DOCUMENTATION</h2>
338
- <p>
339
- RDoc comments are included - run &#8216;rake doc&#8217; to generate
340
- documentation. You can find the latest documentation at:
341
- </p>
342
- <ul>
343
- <li><a href="http://libxml.rubyforge.org/rdoc">libxml.rubyforge.org/rdoc</a>/
344
-
345
- </li>
346
- </ul>
347
- <h2>License</h2>
348
- <p>
349
- See LICENSE for license information.
350
- </p>
351
- <h2>MORE INFORMATION</h2>
352
- <p>
353
- For more information please refer to the documentation. If you have any
354
- questions, please send email to libxml-devel@rubyforge.org.
355
- </p>
356
-
357
- </div>
358
-
359
-
360
- </div>
361
-
362
-
363
- </div>
364
-
365
-
366
- <!-- if includes -->
367
-
368
- <div id="section">
369
-
370
-
371
-
372
-
373
-
374
-
375
-
376
-
377
- <!-- if method_list -->
378
-
379
-
380
- </div>
381
-
382
-
383
- <div id="validator-badges">
384
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
385
- </div>
386
-
387
- </body>
388
- </html>