cancel
Showing results for 
Search instead for 
Did you mean: 

Reading XML file in web dynpro

Former Member
0 Kudos

Hi,

I want to read xml file in webdynpro. please let me know as where to place the file and how to read the file.

Thanks a lot in advance

regards,

Satish

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You can use the code to read a file

The file have to be placed in J2EE server. The code will get the result in a string.


try{
FileInputStream instream;
String s = new DataInputStream( instream = new FileInputStream( <Filepath>)).readLine();
instream.close();
}catch( Exception e)
{}

To extract an XML content; go through this blog;

/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities

Regards

Vinod V

Edited by: Vinod V on May 1, 2008 4:22 PM

Answers (3)

Answers (3)

former_member188598
Contributor
0 Kudos

Hi,

chk this blog,m not sure if it help:

/people/community.user/blog/2006/10/18/how-to-parse-xml-file-uploaded-from-client

Regards

Priya

award point if helps

nikhil_bose
Active Contributor
0 Kudos

You have to place the file where the server can access. You can read the file using java.io.File class

code:


        File xmlFile = new File ("C\\sampledata.xml");
// where C: is in J2EE server itself
       int length = (int) xmlFile.length();
 	try{
	byte data[] = new byte[length]; // 
 	FileInputStream stream = new FileInputStream(xmlFile);
 	stream.read(data);
 	stream.close();
 	}
 	catch(FileNotFoundException e){}
 	catch(IOException e){}

This will get you the xml file as binary

nikhiL

Former Member
0 Kudos

can someone help me in this regards, its urgent.

regards

Satish