|
Thanks David...will give this a try. RR >From: "David Morris" <David.Morris@plumcreek.com> >Reply-To: midrange-l@midrange.com >To: <midrange-l@midrange.com> >Subject: Re: XML downloaded...how to upload? >Date: Fri, 16 Aug 2002 15:24:56 -0600 > >RR, > >In that case you might try a simple Java program running on the >PC. I would avoid the problems associated with RPG and the IFS >and go directly from the PC to your iSeries database. Java is the >language of choice with XML. I am assuming you want a real file >not just the raw XML in the database. I use a framework I built >for database/iSeries/XML support. The database support involves >quite a bit of code, but here is something to get you started: > >package tests; > >import java.util.List; >import java.util.ListIterator; > >import org.jdom.Attribute; >import org.jdom.Document; >import org.jdom.Element; >import org.jdom.JDOMException; > >import org.jdom.input.SAXBuilder; > >/** > * @author David Morris > */ >public class XMLDocument { > > private Document document; > > public static void main(String[] args) { > XMLDocument xmlDocument = new XMLDocument(); > xmlDocument.build(args[0]); > xmlDocument.list(); > System.exit(0); > } > > public void build(String filename) { > > try { > SAXBuilder builder = new SAXBuilder(); > Document doc = builder.build(filename); > listElements(doc.getRootElement()); > } > catch (JDOMException e) { > e.printStackTrace(); > } > } > > public void list() { > listElements(getDocument().getRootElement()); > } > > private void listElements(Element element) { > System.out.println( > "Element name: '" + element.getName() + "' text: '" + >element.getText() + "'"); > > //List all attributes > List attributes = element.getAttributes(); > > for (ListIterator i = attributes.listIterator(); i.hasNext();) >{ > > Attribute attribute = (Attribute) i.next(); > System.out.println( > "Attribute name: '" + attribute.getName() + "' >value: '" + attribute.getValue() > + "'"); > } > > //List all children > List children = element.getChildren(); > > for (ListIterator i = children.listIterator(); i.hasNext();) { > > Element n = (Element) i.next(); > listElements(n); > } > } > > public Document getDocument() { > return document; > } > > public void setDocument(Document document) { > this.document = document; > } >} > >This will list the document elements and attributes to the console. You > >should be able to run this on any PC with the 1.3+ JRE or SDK. For >the database I would use JTOpen. > >David Morris > > >>> the400man@hotmail.com 08/16/02 11:21AM >>> >Thanks David. > >The data is arriving directly to a PC (vendors choice, not mine). I >need to >get it into an EBCDIC- formatted database on the 400. > >RR > >_______________________________________________ >This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list >To post a message email: MIDRANGE-L@midrange.com >To subscribe, unsubscribe, or change list options, >visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l >or email: MIDRANGE-L-request@midrange.com >Before posting, please take a moment to review the archives >at http://archive.midrange.com/midrange-l. _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.