I am trying to parse an xml file using nokogiri. If any body has
experience with nokogiri. I request you to help.
Sample xml file.
I am trying to parse an xml file using nokogiri. If any body has
experience with nokogiri. I request you to help.
Sample xml file.
Hi Venkat,
On Thu, Aug 27, 2009 at 06:49:41AM +0900, Venkat A. wrote:
<onCreateDefault/>
The result is 5.
While the element is at index 1, element
is at index 5. Does any one know why this is.
Your XML contains whitespace nodes. The whitespace nodes are maintained
in the tree that Nokogiri produces. If you iterate over each node, you
can see this in action:
input.xpath(‘//table/column’).each do |column|
# Check each child for blankness
column.children.each { |child| puts child.blank? }
end
If you do not care to maintain whitespace nodes, you can tell the parser
to disable blank nodes like this:
input = Nokogiri::XML(File.new(file)) { |cfg| cfg.noblanks }
I hope that helps!
If you have more questions, I encourage you to join the nokogiri mailing
list which can be found here:
Thanks Aaron
That helped. Good to hear back from the creator of Nokogiri
himself.
Venkat
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs