[jdom-interest] Add root Element to List
    Sinkinson,Andrew [NCR] 
    Andrew.Sinkinson at ec.gc.ca
       
    Tue Dec  2 11:18:31 PST 2003
    
    
  
Hi, 
 I am somewhat new to Jdom and have the following Question sorry if it's
a basic one.  I'm using Xpath to extract a repeating group of elements
from an XML document and storing them in a List.  ( This work's great )
What would be the best way to add a root element to the List so that I
can write out a valid XML document to the file system?  Any help would
be much appreciated.
Thanks,
 Andrew
    try{
      String filename = "C:/SearchGeo/XML/test.xml";
      String teststring = "ALKALINITY";
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(new File(filename));
      XPath dataPath =
XPath.newInstance("/Searchresult/metadata[descendant::enttypl='"+teststr
ing+"']");
     dataPath.
      List results = dataPath.selectNodes(doc);
      /*  Add root element   */
    System.out.println("Results Found "+ results.size() +" metadata
record");
    XMLOutputter Xout = new XMLOutputter();
    Xout.setEncoding("ISO-8859-1");
    Xout.output(results ,System.out);
    }
    catch(JDOMException E){E.printStackTrace();}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20031202/267ab88e/attachment.htm
    
    
More information about the jdom-interest
mailing list