Want to replace tag's src attribute value in xhtml file content.
section_content = section.export_xhtml_content file_path
doc = Nokogiri::HTML(section_content)
unless doc.css('div.image_content').blank?
doc.css('div.image_content img').each do |img|
newsrc = File.basename img[:src]
img.set_attribute('src', newsrc)
end
end
Here src attribute get replaced. But getting XML Parsing Error: XML or text declaration not at start of entity error. After replacing src attribute, resultant content should be in xhtml. Kindly help me to solve this.