WebDynpro 4 Java & Persistence options : Any Idea how 2 read an XML?

Hi,
I was wondering if there is an easy way to store modified (or new) values in a WebDynpro application.
e.g. A User adds a new row to an existing Table UI in Web Dynpro application with create button. I want to save this row either in an XML file, in a table connecting to database or in an ABAP table via RFC connection. Which option is a light (on resources?) and easy to implement. I think it's reading and writing to an XML file. What are the other options, if any?
I've been trying to read an xml file (stored under src/mimes/Components/<com.sap.myComp>/test.xml as below:
//controller code
private static final String FILE_NAME = "test.xml";
private static final WDWebResourceType FILE_EXT = WDWebResourceType.XML;
IWDResource resource = WDWebResource.getWebResource(wdComponentAPI.getDeployableObjectPart(), EditView.FILE_EXT, EditView.FILE_NAME);
wdContext.currentContextElement().setFile(resource);
//end controller code
//view Init() code
IWDResource resource = wdContext.currentContextElement().getFile();
File file = new File(resource.getResourceName().toString());
/* I've also tried below
        FileInputStream fis = null;
     fis = new FileInputStream(file);
        url = file.getAbsolutePath();
        //url is null when printed?
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.getDocumentElement().normalize();
content = doc.getDocumentElement().getNodeName().toString();
//end view Init() code
When I print the value of content, I get it's initial value which is null. What is wrong?? any ideas?
How to get the correct path to the stored xml and how to display its contents? I've read enough posts on SDN but couldn't get it working.
Appreciate your help.
Regards,
N.

hi,
U r retriving the elements by tag name.So it just chks the tag name ie.<book> & gives u array of elements.But u need retrive d attribute of <book> tag itself.
=Solution =====
Add one more statement ----> var[]= doc.getElementsByName("book");
Now u hav book elements as an array & can retrive id in for loop
for(var; var.length;var++)
doc.element[var].id.value

Similar Messages

Maybe you are looking for