public
Description: ruby libxml library targetting speed and ease of use. provides an hpricot-like interface to xml
Homepage: http://trac.hasno.info/fastxml
Clone URL: git://github.com/segfault/fastxml.git
refactored away the Include modules, so that we get documentation of the
ruby-side code alongside the c code
updated the readme to mention licensing and copyright along with a usage
example
segfault (author)
Sun Jun 15 21:39:34 -0700 2008
commit  4c4a11e66dacdbc8c795a50b906915457c94d973
tree    40fabdee15b7de452112af533976baf2b8a99a07
parent  a07cd646109e84174fa21b208e7ff9425d77a22b
0
...
1
 
 
2
3
4
5
 
6
7
8
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
1
2
3
4
5
 
6
7
 
 
 
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -1,9 +1,28 @@
0
-= FastXml, a simple fast xml library using libxml and libxslt
0
+= FastXml
0
+a simple fast xml library using libxml and libxslt with an hpricot-like api
0
 
0
 == Overview
0
 
0
-FastXml is:
0
+FastXml:
0
 
0
-# not standalone, it *requires libxml* and *libxslt*
0
-# it attempts to provide the speediest xml parsing library available for ruby
0
-# it provides an hpricot-like syntax for xml parsing and xslt processing
0
+ 1) is not standalone, it *requires libxml* and *libxslt*
0
+ 2) attempts to provide the speediest xml parsing library available for ruby
0
+ 3) provides an hpricot-like syntax for xml parsing and xslt processing
0
+
0
+== Example
0
+ doc = FastXml( open( 'test.xml ) )
0
+ puts doc.root.name
0
+ puts doc.root.content
0
+
0
+ doc.root.children.each do |node|
0
+ puts "%s => %s" % [ node.name, node.content ]
0
+ end
0
+
0
+ (doc/"/node").each { |node| puts node.inspect } #xpath search
0
+ doc.search( "//node" ).each { |node| puts node.inspect }
0
+
0
+
0
+== Copyright & Licensing
0
+Copyright Mark Guzman 2007-2008
0
+
0
+Please see the LICENSE file for more details. The short version is it's under the same terms as Ruby.
...
25
26
27
28
29
30
 
31
32
33
...
40
41
42
43
44
45
46
47
48
49
50
51
...
65
66
67
68
69
70
71
72
73
74
 
 
75
76
77
...
25
26
27
 
 
 
28
29
30
31
...
38
39
40
 
41
 
 
 
 
42
43
44
...
58
59
60
 
 
 
 
 
 
 
61
62
63
64
65
0
@@ -25,9 +25,7 @@ ID s_readlines;
0
 ID s_to_s;
0
 
0
 void Init_fastxml()
0
-{
0
- VALUE rb_mFastXmlIncludeDoc, rb_mFastXmlIncludeNode, rb_mFastXmlIncludeNodeList;
0
-
0
+{
0
     if (xmlHasFeature(XML_WITH_TREE) == 0)
0
         rb_raise( rb_eRuntimeError, "libxml not built with tree support" );
0
 
0
@@ -40,12 +38,7 @@ void Init_fastxml()
0
     xmlInitParser();
0
     xmlXPathInit();
0
     rb_mFastXml = rb_define_module( "FastXml" );
0
- VALUE rb_mFastXmlInclude = rb_define_module_under( rb_mFastXml, "Include" );
0
     rb_define_const( rb_mFastXml, "LIBXML_VERSION", rb_str_new2( LIBXML_DOTTED_VERSION ) );
0
-
0
- rb_mFastXmlIncludeDoc = rb_define_module_under( rb_mFastXmlInclude, "Doc" );
0
- rb_mFastXmlIncludeNode = rb_define_module_under( rb_mFastXmlInclude, "Node" );
0
- rb_mFastXmlIncludeNodeList = rb_define_module_under( rb_mFastXmlInclude, "NodeList" );
0
 
0
     /* setting symbols */
0
     rb_sValidateDtd = ID2SYM( rb_intern("validate") );
0
@@ -65,13 +58,8 @@ void Init_fastxml()
0
   Init_fastxml_attrlist();
0
   
0
   /* pull in the ruby side of things */
0
- rb_require( "lib/fastxml_lib" );
0
- rb_require( "lib/fastxml_helpers" );
0
-
0
- /* now let's merge those include modules into the main classes */
0
- rb_include_module( rb_cFastXmlDoc, rb_mFastXmlIncludeDoc );
0
- rb_include_module( rb_cFastXmlNode, rb_mFastXmlIncludeNode );
0
- rb_include_module( rb_cFastXmlNodeList, rb_mFastXmlIncludeNodeList );
0
+ rb_require( "lib/fastxml_lib" ); // ruby-side methods for the FastXml classes
0
+ rb_require( "lib/fastxml_helpers" ); // FastXml and FastHtml methods
0
 }
0
 
0
 
...
30
31
32
33
 
34
35
36
...
54
55
56
57
 
58
59
60
61
62
63
64
 
65
66
67
...
30
31
32
 
33
34
35
36
...
54
55
56
 
57
58
59
60
61
62
63
 
64
65
66
67
0
@@ -30,7 +30,7 @@ module FastXml::Common #:nodoc: all
0
   alias :to_s :display
0
 end
0
 
0
-module FastXml::Include::Doc #:nodoc:
0
+class FastXml::Doc
0
   include FastXml::Common
0
   
0
   def doc?
0
@@ -54,14 +54,14 @@ module FastXml::Include::Doc #:nodoc:
0
   end
0
 end
0
 
0
-module FastXml::Include::Node #:nodoc:
0
+class FastXml::Node
0
   include FastXml::Common
0
   def doc?
0
     false
0
   end
0
 end
0
 
0
-module FastXml::Include::NodeList #:nodoc:
0
+class FastXml::NodeList
0
   def [](idx)
0
     self.entry(idx)
0
   end

Comments

    No one has commented yet.