Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How use XML-Parser in Web Dypro (how get filename)

Hi everybody,

i want to use the saxparser to read a xml-file via a Fileupload-UI element. In Web Dynpro it is not possible to get the path of a file which was on a client through the Fileupload-UI. So how can i use a xml-parser when i have to give it the file name?

Is it possible to use the "resource" of the Fileupload-UI instead ot the filename? How can i call the parser?


                    SAXParser saxParser= null;
		
	try{    			
		SAXParserFactory factory = SAXParserFactory.newInstance();			
		saxParser = factory.newSAXParser();			
		saxParser.parse( new File(??????), new  Gaeb());

	}catch (Exception ex){
		ex.printStackTrace();
	} 

regards,

Sid

Former Member
Former Member replied

Hi,

When you create a context attribute of type Resource and bind it to the resource property of ileuplod UI element which will return you the Input stream, you can give the Input stream as input to sax parser parse method.

SAXParser saxParser= null;

try{

SAXParserFactory factory = SAXParserFactory.newInstance();

saxParser = factory.newSAXParser();

saxParser.parse( wdContext.currentContextElement().getAttch().read(true), new Gaeb());// here attch is the context attribute of type Resource

}catch (Exception ex){

ex.printStackTrace();

}

Regards,

Naga

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question