Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
既存の XML ドキュメントの更新に行き詰まっています。ルート ノードに別の要素を追加する必要があります。追加する必要がありますが、を使用するXMLWriterと、オブジェクトがオーバーライドされ、古いデータがすべて失われます。既存のドキュメントに別のノードを追加するにはどうすればよいですか?
XMLWriter
つまり、追加です。Dom4jライブラリを使用しています。
XMLWriter行く方法ではありません。Node クラスとそのサブクラスのメソッドを使用して、ノードを追加、削除、またはその他の方法で非常に簡単に操作できます。例えば:
Element root = document.getRootElement(); Element author = root.addElement("author");