cancel
Showing results for 
Search instead for 
Did you mean: 

create XML file in KM

Former Member
0 Kudos
63

Hi,

we have an XML string which we need to write into an XML file in KM.

could someone please suggets code to do this.

Thanks,

Rocky

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member1
Active Participant
0 Kudos

Hi

Please find the code

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();

//create an ep5 user from the retrieved user

IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);

IResourceContext resourseContext = new ResourceContext(ep5User);

RID pathRID =

RID.getRID(

"/documents/"

+ "/News");

IResourceFactory resourseFactory = ResourceFactory.getInstance();

//get an instance of the current folder under which we have to create subfolders

ICollection collection =

(ICollection) resourseFactory.getResource(

pathRID,

resourseContext);

File tempFile = new File("temp.xml");

tempFile.createNewFile();

FileWriter writer = new FileWriter(tempFile);

writer.write(str);

writer.close();

BufferedInputStream bufInStream =

new BufferedInputStream(new FileInputStream(tempFile));

Content con = new Content(bufInStream, "byte", -1);

com.sapportals.wcm.repository.IResource resource = null;

// Creating XML File

resource =

collection.createResource(ParentTitle + ".xml", null, con);

} catch (NotSupportedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (AccessDeniedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SetPropertiesException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (WDUMException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (ResourceException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (UserManagementException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}