0
Nokogiriノード要素から属性を削除しようとしています。ここでremove_attributeは、単に属性nokogiriを削除する代わりにnilノード要素を返す
は、最初のノードの要素である:
=> #(Element:0x3fed0eaf2ef0 {
name = "ins",
namespace = #(Namespace:0x3fed0ed24408 { prefix = "w", href = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" }),
attributes = [
#(Attr:0x3fed0eb1e528 { name = "id", namespace = #(Namespace:0x3fed0ed24408 { prefix = "w", href = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" }), value = "0" }),
#(Attr:0x3fed0eb1e514 { name = "author", namespace = #(Namespace:0x3fed0ed24408 { prefix = "w", href = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" }), value = "Mitchell Gould" })
#(Attr:0x3fed0eb1e500 { name = "date", namespace = #(Namespace:0x3fed0ed24408 { prefix = "w", href = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" }), value = "2016-10-15T14:43:00Z" })]
})
私が行うと:
first = all_ins_nodes.first.remove_attribute("name")
first => nil
私は唯一のノード全体の要素を削除しない属性を削除します。これどうやってするの?
返信が遅れました。その有用で分かりやすい答えをありがとう。 – chell