Disons que j'ai XML qui ressemble à ceci:Obtenir un seul élément enfant avec un nom donné avec Nokogiri
<paper>
<header>
</header>
<body>
<paragraph>
</paragraph>
</body>
<conclusion>
</conclusion>
</paper>
Est-il possible que je peux obtenir conclusion
, sans faire une boucle laide comme:
for child in paper.children do
if child.name == "conclusion"
conclusion = child
end
end
puts conclusion
Idéalement quelque chose comme python Element.find('conclusion')
.
Avez-vous vu [ce tutoriel] (http://www.nokogiri.org/tutorials/searching_a_xml_html_document.html)? Je l'ai trouvé en recherchant "nokogiri trouver l'élément par nom" – alexanderbird