ID を見つけるには、次のようにします。
id = doc.xpath("//ID").text
ここで、doc は、xml ドキュメントを読み込んで作成された Nokogiri オブジェクトです。
要素 ID が必要なものかどうかを確認するには、次を試してください。
if id == "1234"
あなたのxmlファイルから、これはtrueを返すはずです
最後に、説明全体を削除するには:
doc.xpath("//Description").remove
あなたが探しているのはこれです:
doc = Nokogiri::XML(File.open("test.xml")) #create Nokogiri object from "test.xml"
id = doc.xpath("//ID").text #this will be a string with the id
doc.xpath("//Description").remove if id == "1234" #returns true with your xml document and remove the entire Description element."