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
가 난 단지 전체 노드 요소를 삭제하지 않는 속성을 제거 할. 어떻게해야합니까? 바로 여기
first = all_ins_nodes.first.remove_attribute("name")
여러 줄
first = all_ins_node.first
first.remove_attribute("name")
이유는 .remove_attribute
이 분명 전무를 반환한다는 것입니다으로 분할해야
늦은 답변에 사과드립니다. 그 도움이되고 분명한 대답에 감사드립니다. – chell