From aidy.lewis at googlemail.com Mon Apr 12 07:22:38 2010 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 12 Apr 2010 12:22:38 +0100 Subject: [Nokogiri-talk] Unable to retrieve text value from xpath Message-ID: Hi, The XML I am parsing is attached and I need this text value The xPath to this element is: /stubRequests/stubRequest[4]/requestBody However, nokogiri is returning just the " " with that xpath input = Nokogiri::XML(File.new("D:\\response.xml")) second_request_body = input.root.xpath("/stubRequests/stubRequest[4]/requestBody") puts "the request body is: #{second_request_body}" I have also tried input.root.xpath("/stubRequests/stubRequest[4]/requestBody").text() This will return the text value of the first xml requestBody element input.root.xpath("/stubRequests/stubRequest[1]/requestBody") Cheers Aidy -------------- next part -------------- A non-text attachment was scrubbed... Name: response.xml Type: text/xml Size: 17663 bytes Desc: not available URL: From byrnejb at harte-lyne.ca Mon Apr 12 08:26:45 2010 From: byrnejb at harte-lyne.ca (James B. Byrne) Date: Mon, 12 Apr 2010 08:26:45 -0400 (EDT) Subject: [Nokogiri-talk] Nokogiri-talk Digest, Vol 9, Issue 1 In-Reply-To: References: Message-ID: <51827.216.185.71.24.1271075205.squirrel@webmail.harte-lyne.ca> On Mon, April 12, 2010 07:22, nokogiri-talk-request at rubyforge.org wrote: > Send Nokogiri-talk mailing list submissions to > nokogiri-talk at rubyforge.org > . . . > > Today's Topics: > > 1. Re: Comparing documents (Aaron Patterson) > 2. Re: Comparing documents (Phlip) > 3. Re: Comparing documents (Julien Genestoux) > 4. Re: Comparing documents (Phlip) > 5. How to convert this XML parsing code to use a stream? (Jed > Hurt) > 6. How to convert this XML parsing code to use a stream? (Jed > Hurt) > 7. Help with XML Builder (Antel) > 8. Re: Help with XML Builder (Aaron Patterson) > 9. Need basic xml help (James B. Byrne) > 10. How to convert this XML parsing code to use a stream? (Jed > Hurt) > 11. Re: Need basic xml help (Aaron Patterson) > 12. Re: How to convert this XML parsing code to use a stream? > (Aaron Patterson) > 13. Re: Need basic xml help (James B. Byrne) > 14. Re: Need basic xml help (Phlip) > 15. Re: Help with XML Builder (Antel) > 16. Re: Help with XML Builder (Antel) > 17. Re: Help with XML Builder (Antel) > 18. Re: Help with XML Builder (Antel) > 19. Re: Need basic xml help (James B. Byrne) > 20. bug tracker is changing (Aaron Patterson) > 21. Re: How to convert this XML parsing code to use a stream? > (Jed Hurt) > 22. Memory problem with Nokogiri and rack (Adam van den Hoven) > 23. Re: Memory problem with Nokogiri and rack (Aaron Patterson) > 24. Re: Help with XML Builder (Antel) > 25. Re: Memory problem with Nokogiri and rack (Adam van den Hoven) > 26. Re: Memory problem with Nokogiri and rack (Mike Dalessio) > 27. Ruby Rails and Nokogiri (James B. Byrne) > 28. Re: Memory problem with Nokogiri and rack (Aaron Patterson) > 29. [SOLVED] Re: Ruby Rails and Nokogiri (James B. Byrne) > 30. Re: Memory problem with Nokogiri and rack (Adam van den Hoven) > 31. Re: Memory problem with Nokogiri and rack (Aaron Patterson) > 32. Re: Memory problem with Nokogiri and rack (Adam van den Hoven) > 33. Re: Memory problem with Nokogiri and rack (Mike Dalessio) > 34. Re: Memory problem with Nokogiri and rack (Mike Dalessio) > 35. Re: Memory problem with Nokogiri and rack (Adam van den Hoven) > 36. Encoding bug (rubikitch at ruby-lang.org) > 37. Re: Encoding bug (Aaron Patterson) > 38. Re: Encoding bug (rubikitch at ruby-lang.org) > 39. Re: Encoding bug (Aaron Patterson) > 40. Re: Encoding bug (rubikitch at ruby-lang.org) > 41. paginating xml doc fragments -- help?! (Matt Mitchell) > 42. Re: paginating xml doc fragments -- help?! (Aaron Patterson) > 43. Re: Encoding bug (Aaron Patterson) > 44. [ANN] nokogiri 1.3.0rc1 has been released! (Aaron Patterson) > 45. Re: [ANN] nokogiri 1.3.0rc1 has been released! (Phlip) > 46. Re: [ANN] nokogiri 1.3.0rc1 has been released! (Aaron > Patterson) > 47. v1.2.4 broke assert_xhtml! (Phlip) > 48. Re: v1.2.4 broke assert_xhtml! (Phlip) > 49. Re: v1.2.4 broke assert_xhtml! (Phlip) > 50. Re: v1.2.4 broke assert_xhtml! (Aaron Patterson) > 51. Re: v1.2.4 broke assert_xhtml! (Phlip) > 52. Spaces in predicate searches (pYuri.fy) > 53. Re: Spaces in predicate searches (Aaron Patterson) > 54. Re: Spaces in predicate searches (Aaron Patterson) > 55. problem after upgrading from 1.1.0 to 1.2.3 (Xavi Caball?) > 56. Re: problem after upgrading from 1.1.0 to 1.2.3 (Aaron > Patterson) > 57. Re: problem after upgrading from 1.1.0 to 1.2.3 (Xavi Caball?) > 58. Re: problem after upgrading from 1.1.0 to 1.2.3 (Xavi Caball?) > 59. Re: problem after upgrading from 1.1.0 to 1.2.3 (Mike > Dalessio) > 60. Re: problem after upgrading from 1.1.0 to 1.2.3 (Xavi Caball?) > 61. Namespaces giving me headaches (Bob Fitterman) > 62. Re: Namespaces giving me headaches (Aaron Patterson) > 63. Re: Namespaces giving me headaches (Bob Fitterman) > 64. Re: Namespaces giving me headaches (Aaron Patterson) > 65. Re: Namespaces giving me headaches (Bob Fitterman) > 66. Building documents with namespaces (Jeff Smick) > 67. Re: Building documents with namespaces (Aaron Patterson) > 68. Re: Building documents with namespaces (Jeff Smick) > 69. more namespace stuff (Jeff Smick) > 70. Re: more namespace stuff (Aaron Patterson) > 71. next_sibling not working? (Xavi Caball?) > 72. Re: next_sibling not working? (Mike Dalessio) > 73. Nokogiri::XML::SAX::Document and elements with invalid xml > contents (Jesse Clark) > 74. Re: Nokogiri::XML::SAX::Document and elements with invalid > xml contents (Jeff Hodges) > 75. Re: Nokogiri::XML::SAX::Document and elements with invalid > xml contents (Jesse Clark) > 76. Re: Nokogiri::XML::SAX::Document and elements with invalid > xml contents (Jeff Hodges) > 77. Re: Nokogiri::XML::SAX::Document and elements with invalid > xml contents (Jesse Clark) > 78. [ANN] nokogiri 1.3.0 Released (Aaron Patterson) > 79. Re: [ANN] nokogiri 1.3.0 Released (Antel) > 80. [ANN] nokogiri 1.3.1 Released (Aaron Patterson) > 81. parsing html with tabs (Joe Williams) > 82. Re: parsing html with tabs (Mike Dalessio) > 83. Re: parsing html with tabs (Mike Tracy) > 84. Re: parsing html with tabs (Joe Williams) > 85. style, script and comments getting scrubbed in before/after > (Vamsee Kanakala) > 86. Trouble with xpath (Alf Mikula) > 87. Re: Trouble with xpath (Aaron Patterson) > 88. Re: Trouble with xpath (Alf Mikula) > 89. move to google groups (Aaron Patterson) > 90. Re: move to google groups (Jeff Smick) > 91. Re: move to google groups (Jeff Hodges) > 92. Re: move to google groups (Jeff Hodges) > 93. Re: move to google groups (Matt Mitchell) > 94. writing attributes to a nokogiri doc (m.zeckinger) > 95. Re: move to google groups (Antel) > 96. Re: writing attributes to a nokogiri doc (Mike Dalessio) > 97. [*bump*] Node/NodeSet.before/after cleaning out script, style > tags (Vamsee Kanakala) > 98. Re: [*bump*] Node/NodeSet.before/after cleaning out script, > style tags (Mike Dalessio) > 99. Re: [*bump*] Node/NodeSet.before/after cleaning out script, > style tags (Mike Dalessio) > 100. Re: [*bump*] Node/NodeSet.before/after cleaning out script, > style tags (Vamsee Kanakala) > 101. Parsing an HTML document (James B. Byrne) > 102. Re: Parsing an HTML document (Aaron Patterson) > 103. Re: move to google groups (Aaron Patterson) > 104. Replace Node w/ Children (Trans) > 105. Running/installing gem on 64 bit OSX 10.6 (Ben Lovell) > 106. Re: Replace Node w/ Children (Aaron Patterson) > 107. Re: Running/installing gem on 64 bit OSX 10.6 (Aaron > Patterson) > 108. Re: Parsing an HTML document (James B. Byrne) > 109. Re: Running/installing gem on 64 bit OSX 10.6 (Ben Lovell) > 110. Re: Parsing an HTML document (Aaron Patterson) > 111. Re: Running/installing gem on 64 bit OSX 10.6 (Aaron > Patterson) > 112. Re: Parsing an HTML document (James B. Byrne) > 113. Re: Running/installing gem on 64 bit OSX 10.6 (Ben Lovell) > 114. Re: Parsing an HTML document (Aaron Patterson) > 115. [ANN] Nokogiri mailing list is moving to Google Groups > (Aaron Patterson) > 116. Re: Parsing an HTML document (James B. Byrne) > 117. Re: Parsing an HTML document (Aaron Patterson) > 118. Re: Running/installing gem on 64 bit OSX 10.6 (Gregory > Clarke) > 119. how to get to_xhtml to produce a fragment without the title? > (Phlip) > 120. Re: writing attributes to a nokogiri doc (Vamsee Kanakala) > 121. Re: writing attributes to a nokogiri doc (m.zeckinger) > 122. Re: writing attributes to a nokogiri doc (Aaron Patterson) > 123. How to configure xml.builder to call Nokogiri? (Phlip) > 124. Enterprise Ruby! (Phlip) > 125. nokogiri 1.3.3 osx: Nokogiri::XML::Element broken? > (m.zeckinger) > 126. Unable to retrieve text value from xpath (aidy lewis) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 10 Apr 2009 08:46:29 -0700 . . . > Message: 2 > Date: Fri, 10 Apr 2009 11:43:51 -0700 . . . > Message: 3 > Date: Fri, 10 Apr 2009 14:18:57 -0700 . . . . . . > Message: 4 > Date: Fri, 10 Apr 2009 14:33:17 -0700 Why is the mailing list digest processor resending messages from a year ago? -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 From aidy.lewis at googlemail.com Thu Apr 22 13:18:17 2010 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 22 Apr 2010 18:18:17 +0100 Subject: [Nokogiri-talk] object space disabled Message-ID: Hi, I am using JRuby and receiving this exception when I attempt to do the rspec assertion. Does anyone know why? c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/xml_document.rb:42 warning: ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/xml_document.rb:42 warning: ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/common_node.rb:11 warning: ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable Thanks require 'rubygems' require 'java' require 'nokogiri' require 'spec' class MarkUpParser @@input = nil def process_mark_up(xml) raise "The XML file does not exist" if ! File.exists?(xml) @@input = Nokogiri::XML.parse(File.read(xml)) end def count_elements(xpath) @@input.search(xpath).size end def print_output puts @@input end end mark_up_parser = MarkUpParser.new mark_up_parser.process_mark_up("D:\\response.xml") mark_up_parser.print_output mark_up_parser.count_elements("/stubRequests/stubRequest").should == 5 Aidy -------------- next part -------------- A non-text attachment was scrubbed... Name: response.xml Type: text/xml Size: 24387 bytes Desc: not available URL: From mike.dalessio at gmail.com Thu Apr 22 14:09:16 2010 From: mike.dalessio at gmail.com (Mike Dalessio) Date: Thu, 22 Apr 2010 14:09:16 -0400 Subject: [Nokogiri-talk] object space disabled In-Reply-To: References: Message-ID: Hi Aidy, Nokogiri 1.4.1 uses ObjectSpace to perform memory management on some of the native libxml objects. Currently Nokogiri master does not depend on ObjectSpace, so you should be able to use one of the nightly builds to get around this. We expect to release 1.4.2 very very soon. -m On Thu, Apr 22, 2010 at 1:18 PM, aidy lewis wrote: > Hi, > > I am using JRuby and receiving this exception when I attempt to do the > rspec assertion. > > Does anyone know why? > > c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/xml_document.rb:42 > warning: ObjectSpace is disabled; _id2ref only supports immediates, > pass -X+O to enable > c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/xml_document.rb:42 > warning: ObjectSpace is disabled; _id2ref only supports immediates, > pass -X+O to enable > c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/common_node.rb:11 > warning: ObjectSpace is disabled; _id2ref only supports immediates, > pass -X+O to enable > > Thanks > > > require 'rubygems' > require 'java' > require 'nokogiri' > require 'spec' > > class MarkUpParser > ? ? ? ?@@input = nil > > ? ? ? ?def process_mark_up(xml) > ? ? ? ? ?raise "The XML file does not exist" if ! File.exists?(xml) > ? ? ? ? ? ? ? ?@@input = Nokogiri::XML.parse(File.read(xml)) > ? ? ? ?end > > ? ? ? ?def count_elements(xpath) > ? ? ? ? ? ? ? ?@@input.search(xpath).size > ? ? ? ?end > > ? ? ? ?def print_output > ? ? ? ? ? ? ? ?puts @@input > ? ? ? ?end > end > > mark_up_parser = MarkUpParser.new > mark_up_parser.process_mark_up("D:\\response.xml") > mark_up_parser.print_output > mark_up_parser.count_elements("/stubRequests/stubRequest").should == 5 > > > Aidy > > _______________________________________________ > Nokogiri-talk mailing list > Nokogiri-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/nokogiri-talk > > From aidy.lewis at googlemail.com Thu Apr 22 14:15:32 2010 From: aidy.lewis at googlemail.com (aidy lewis) Date: Thu, 22 Apr 2010 19:15:32 +0100 Subject: [Nokogiri-talk] object space disabled In-Reply-To: References: Message-ID: Hi Mike, Thanks for getting back. Found a workaround, by setting object space to true, before requiring rubygems require 'java' JRuby.objectspace = true require 'rubygems' Aidy On 22 April 2010 19:09, Mike Dalessio wrote: > Hi Aidy, > > Nokogiri 1.4.1 uses ObjectSpace to perform memory management on some > of the native libxml objects. > > Currently Nokogiri master does not depend on ObjectSpace, so you > should be able to use one of the nightly builds to get around this. We > expect to release 1.4.2 very very soon. > > -m > > On Thu, Apr 22, 2010 at 1:18 PM, aidy lewis wrote: >> Hi, >> >> I am using JRuby and receiving this exception when I attempt to do the >> rspec assertion. >> >> Does anyone know why? >> >> c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/xml_document.rb:42 >> warning: ObjectSpace is disabled; _id2ref only supports immediates, >> pass -X+O to enable >> c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/xml_document.rb:42 >> warning: ObjectSpace is disabled; _id2ref only supports immediates, >> pass -X+O to enable >> c:/jruby-1.5.0.RC1/lib/ruby/gems/1.8/gems/nokogiri-1.4.1-java/lib/nokogiri/ffi/structs/common_node.rb:11 >> warning: ObjectSpace is disabled; _id2ref only supports immediates, >> pass -X+O to enable >> >> Thanks >> >> >> require 'rubygems' >> require 'java' >> require 'nokogiri' >> require 'spec' >> >> class MarkUpParser >> ? ? ? ?@@input = nil >> >> ? ? ? ?def process_mark_up(xml) >> ? ? ? ? ?raise "The XML file does not exist" if ! File.exists?(xml) >> ? ? ? ? ? ? ? ?@@input = Nokogiri::XML.parse(File.read(xml)) >> ? ? ? ?end >> >> ? ? ? ?def count_elements(xpath) >> ? ? ? ? ? ? ? ?@@input.search(xpath).size >> ? ? ? ?end >> >> ? ? ? ?def print_output >> ? ? ? ? ? ? ? ?puts @@input >> ? ? ? ?end >> end >> >> mark_up_parser = MarkUpParser.new >> mark_up_parser.process_mark_up("D:\\response.xml") >> mark_up_parser.print_output >> mark_up_parser.count_elements("/stubRequests/stubRequest").should == 5 >> >> >> Aidy >> >> _______________________________________________ >> Nokogiri-talk mailing list >> Nokogiri-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/nokogiri-talk >> >> > _______________________________________________ > Nokogiri-talk mailing list > Nokogiri-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/nokogiri-talk > From julien.genestoux at gmail.com Sun Apr 25 11:22:08 2010 From: julien.genestoux at gmail.com (Julien Genestoux) Date: Sun, 25 Apr 2010 17:22:08 +0200 Subject: [Nokogiri-talk] Comparing documents In-Reply-To: <49DFBB1D.6090808@gmail.com> References: <26c0cf900904092322g352faed6x57baa7fab45fc7f4@mail.gmail.com> <6959e1680904100846m32494887rdb275aa00647ce8c@mail.gmail.com> <26c0cf900904101418h7237b8a2r4e42afd08e739abb@mail.gmail.com> <49DFBB1D.6090808@gmail.com> Message-ID: Phil, For some reason, I missed your last message. Anyway, I added a === to our Nokogiri Node's : http://gist.github.com/378473 It fits the need on my end :) Thanks! On Fri, Apr 10, 2009 at 11:33 PM, Phlip wrote: > Julien Genestoux wrote: > > Thank you guys for the responses... >> >> It is actually for rspec purposes that I need to compare an expected doc >> and the actual generated. >> > > I suspect assert_xhtml can do this. > > Install the gems nokogiri and assert2. Then require 'assert2/xhtml' > > > >> Aaron, here is how I see the 7 questions : >> 1. Is the name the same? yes, it should >> 2. How about attributes? same >> 3. How about the namespace? same >> 4. What about number of children? same >> 5. Are all the children the same? same >> 6. Is it's parent node the same? same >> 7. What about it's position relative to sibling nodes? nope! >> > > Then... > > @response.body.should be_html_with{ > xml_tag :attribute1 => 'value1' do > nested_tag :attribute2 => 'value2', > :xpath! => '42 = count(*) and parent::xml_tag and position() = 0' > end > } > > Ask if that doesn't work - it's exactly what I invented assert_xhtml, with > the slight matter I will drop your XML into Nokogiri::HTML. That may or may > not be a problem! > > Naturally, this library needs a .be_xml_with{}, for completeness. > > _______________________________________________ > Nokogiri-talk mailing list > Nokogiri-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/nokogiri-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailtome200420032002 at yahoo.com Thu Apr 29 18:19:45 2010 From: mailtome200420032002 at yahoo.com (john blair) Date: Thu, 29 Apr 2010 15:19:45 -0700 (PDT) Subject: [Nokogiri-talk] Building nokogiri extension that is statically linked against libxml, and libxslt libs Message-ID: <133946.66561.qm@web53108.mail.re2.yahoo.com> I am new to ruby. If I do gem install nokogiri, the native extension dynamically links against libxml, libxslt libs. I want to statically link against those libs. How should I go about this?