on 07-23-2010 8:26 AM
Hi All,
below is my requirement.
i have to transform a simple XML structure to a file using custom adapter module.
I KNOW , i can use content coversion/java mapping etc... to achive this..
but i want to do this using custom adapter module.
basically i am not getting any clue.... how i can read an XML document in the reciver adapter module and how to write in a file.
i know SAX parser ... but in adapter module inside the method
moduleContext
... how to convert the xml... not sure.. do i need to use any parser in module also??
please provide me sample code....
thanks...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
but i want to do this using custom adapter module.
Wont the available module (MessageTransformBean) help: http://help.sap.com/saphelp_nw04/Helpdata/EN/24/4cad3baabd4737bab64d0201bc0c6c/content.htm
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IF YOU ARE LOOKING FOR ADAPTER MODULE SAMPLE CODE SEARCH IN SDN.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raja,
i have serached whole SDN , but could not find relevent code sample for XML to flat file conversion.
Actuly i am trying to write a flat file from 4 level XML structure..
i know there are several alternatives.. XSLT/intermediate mapping etc..
but i WANT TO DO THIS IN Adapter module only..
Hi,
Try to read the XML file in the form of input stream inside ur adapter module and then start parsing that input stream(which contains XML data) :
InputStream inps = (InputStream) xpld.getInputStream();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(inps);
doc.getDocumentElement().normalize();
NodeList nodeLst = doc.getElementsByTagName("RootNode");
for (int x = 0; x < nodeLst.getLength(); x++) {
Node fstNode = nodeLst.item(s);
if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
Element fstElmnt = (Element) fstNode;
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("Element1");
Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
NodeList fstNm = fstNmElmnt.getChildNodes();
String Value1 =((Node) fstNm.item(0)).getNodeValue();//value1 is the value inside XML element "Element1"
NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("Element2");
Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
NodeList lstNm = lstNmElmnt.getChildNodes();
String Value2 = ((Node) lstNm.item(0)).getNodeValue();//value2 is the value inside XML element "Element2"
}
I havent tried this but i think it should work:)
Thanks
Amit
Edited by: AmitSri on Jul 26, 2010 12:45 PM
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.