I'm parsing a document.xml file using Nokogiri, extracted from .docx file and need to get values of attributes with names, like "w:val
".
This is a sample of the source XML:
<w:document>
<w:body>
<w:p w:rsidR="004D5F21" w:rsidRPr="00820E0B" w:rsidRDefault="00301D39" pcut:cut="true">
<w:pPr>
<w:jc w:val="center"/>
</w:pPr>
</w:body>
</w:document>
This is a sample of the code:
require 'nokogiri'
doc = Nokogiri::XML(File.open(path))
doc.search('//w:jc').each do |n|
puts n['//w:val']
end
There is nothing in the console, only empty lines. How can I get the values of the attributes?