Update a single XML entity using Hpricot in Ruby? -
I am using an XML file to process. I randomly want to display some quotes from the file, and then I want to track how often each quote was displayed. Is it possible to update an item within the XML file using HPCrot (or is there any other solution that can do this for me) or should I re-write the entire XML file every time an item is displayed ?
I used to work with nokogiri instead of hpricot (it is quite fast).
I did something like this:
> #! / Usr / bin / env ruby is required 'RubyGoms' requirement' Notory 'FNAME = "/home/kirill/books.xml" doc = Nokogiri :: XML (Open (FNAME)) doc.search (' Title '). Each {| Node | Node.content = node.content.reverse} file. New (FNAME, 'w') Write to the doctor until doc.validate
Do you have such a large file, it is slow?
Or do not you want me to understand anything else?
Comments
Post a Comment