Posted By

dalcacer on 03/09/10


Tagged

xml parser JDOM


Versions (?)

Basics JDOM


 / Published in: Java
 

  1. import java.io.*;
  2. import org.jdom.*;
  3. import org.jdom.input.*;
  4. import org.jdom.output.*;
  5.  
  6. public class FirstRecipeJDOM {
  7. public static void main(String[] args) {
  8. try {
  9. Document d = new SAXBuilder().build(new File(args[0]));
  10. Namespace ns = Namespace.getNamespace("http://recipes.org");
  11. Element e = new Element("collection");
  12. e.addContent(d.getRootElement().getChild("recipe", ns).detach());
  13. Document n = new Document(e);
  14. new XMLOutputter().output(n, System.out);
  15. } catch (Exception e) {e.printStackTrace();}
  16. }
  17. }

Report this snippet  

You need to login to post a comment.