I have a small problem when trying build an XML document with Nokogiri.
I want to call one of my elements “text” (see the the very bottom of the pasted code below). Normally, to create a new element I do something like the following xml.text — but it seems to be .text is a method already used by Nokogiri to do something else. Thus when I write this line xml.text Nokogiri is not creating a new element called <text> but is just writing the text meant to be the content of the element. How can I get Nokogiri to actually make an element called <text>?
builder = Nokogiri::XML::Builder.new do |xml|
xml.TEI("xmlns" => "http://www.tei-c.org/ns/1.0"){
xml.teiHeader {
xml.fileDesc{
xml.titleStmt{
xml.title "Version Log for #{title}"
xml.author "Jeffrey C. Witt"
}
xml.editionStmt{
xml.edition('n' => "#{ed_no}") {
xml.date('when' => "#{newDate}")
}
}
xml.publicationStmt{
xml.publisher "#{publisher}"
xml.pubPlace "#{pubPlace}"
xml.availability("status" => "free") {
xml.p "Published under a Creative Commons Attribution ShareAlike 3.0 License"
}
xml.date("when" => "#{newDate}")
}
xml.sourceDesc {
xml.p "born digital"
}
}
}
xml.text "test"{
xml.body {
xml.p "test document
}
}
}
From the docs:
So, all you have to do is add an underscore after
text, like so: