0
イメージタグが内部にあるSVGドキュメントがあります。しかしdoc.search('//image')
は空の配列を返しますSVGファイルのNokogiriでタグを削除するには
doc = File.open("cartes_des_risques.svg") { |f| Nokogiri::XML(f) }
doc.search('//image').each do |node|
node.remove
end
file = File.open("formmatted_map.svg", "w")
file.write(doc)
:私はそれを解析し、鋸山ですべての画像タグを削除し、別のファイルに書き換えしようとしています。
私が修正しようとしているドキュメントは、次のようになり、画像タグembedds大きなSVGファイルです:
<image a:adobe-opacity-share="1" width="338" height="338" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVYAAAFWCAYAAAAyr7WDAAAACXBIWXMAAC4jAAAuIwF4pT92AAAA
GXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAEelJREFUeNrs3dGu5CgShOHi1Lz/
K7Oau92VRprutiEy8wupr/qUDQnxO8GAPx8iIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi
qqQlBDSov21NQMBK+hIAEzOQ/tJagEuMQvoG4BLzkH4AtMRQpN0JaInBtDMBLTEcaVuQJeYj7UlA
y4ikDQlkiSm1GwEsMShpLwJZRiVtRABLTKttCGSJeUmbEMAyMWkHAlhiaPEngCXGFncigGVwEm8C
WGJ0sSaAJWYXYyKAZXoSWwJY5icxJXAlEBBPIoAFAnEkAlhAIPErG0NgEENgEDsxAg8x0vHFjHrH
A0zEgynES/3BRQwYRazUGWTUm3HESF0JcMCVkcRHHcFHHZlKbNQNgNSNwcREvQiIwJXZRsVD+wKS
+jCeWKgLwKoLA4qDOhAogSsztouBNgRZ5WdKdVd+GgSokXCdas6l7ARSys2k6mwZGENXrtcouE4D
61Jm5W9k9q28Or26Ki8AKO8IuE4B61JW/WYADJSTQdSxUDm9MKsDBnBlGPULLieY1obEFjfmMaRW
HpCdCa+WcLWERxnBtD80wJWp2tdpKQPIAlhvuDomb075wBRAwJXZWtUFUCkJJODKdOXrssTj9fLb
QdULYuXh2gWsoCpzl62Bq47ev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CVGYlbUZgSkyq/QhMiTFJWxKYMiNpVwJTYkDSzmBKDEfaHEiJyUgfICAl
piL9AkiJgUhfAVBiFtKPwJMYgmhKfwNNIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiL6
H/1HgAEArVlNIehstlUAAAAASUVORK5CYII=" transform="matrix(0.24 0 0 0.24 839.2388 2258.6909)">
</image>
どのように私は鋸山で、このSVGファイルを変更することができますか?
私はあなたのクエリで指定する必要がある名前空間に 'image'があると思っています。ファイルは名前空間を使用していますか? – matt