on 01-25-2006 2:40 PM
Hi all,
I'm using a public WS and the service returns me a (very long) string containing XML code.
I'd like to display those data in a WD table: can anyone tell how to retrieve the fields (to form columns) and the data (to fill lines) ?
Thanks in advance !
Hi,
Here is the first step code to convert the xml string to a xml document using Dom4j.
Document doc = DocumentHelper.parseText(xmlString);
Element root = doc.getRootElement();
parseNode(root);
Code your parseNode(Element e) method to parse all the nodes of root tag to populate your WD table.
Regards,
Uma
Message was edited by: Uma Maheswari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Francois,
these are the option, for the moment I can think of, to convert a XML string to Java Objects:
1a. First, use the SAP XML Parser's DOM builder and create a DOM as an intermediary step. Then traverse the DOM and populate your WD table
1b. A variant of 1a would be to use and XML library like dom4j or XOM, to create a DOM, which is less brittle to handle, then the original (W3C) DOM
2. First, use a Java/XML binding framework like JAXB, Digester or JiXB to convert your XML string to a Java Object tree. Then traverse the created object and populate your WD table. Digester and JiXB are very flexible, and by chance you may be able to create/populate your WD table already in the first step.
My advise: use Digester or JiXB
Download sites:
- dom4j: http://www.dom4j.org/download.html
- XOM: http://www.xom.nu/
- Digester: http://jakarta.apache.org/site/downloads/downloads_commons-digester.cgi
- JiXB: http://jibx.sourceforge.net/
- JAXB: http://java.sun.com/webservices/jaxb/
Good Luck!
Gregor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you consider parsing the string with SAX Parser and then populate your webdynpro context with values being intercepted while parsing with your own handler?
Look at http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/helpers/DefaultHandler.html
you may want to extend the default handler.
Hope this helps.
Kind regards, Vitaliano.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.