cancel
Showing results for 
Search instead for 
Did you mean: 

Encoding for content in KM

Former Member
0 Kudos

Hi All,

I'm modifying and updating an existing file in KM. I use DOM to parse the file and update it as follows:

Element rootElem = doc.getDocumentElement();

<code to update rootElement>

Finally, I want to convert the Document or rootElement to IContent and update it in the repository. I use the following code:

IContent newContent = (IContent)MimeUtils.getContentFromString(rootElem.toString(),"text/xml");

IContent newFile = new Content(newContent.getInputStream(),"text/xml",newContent.getContentLength(),"ISO-8859-1",null);

resource.updateContent(newFile);

The file is updated with the above code, however the encoding "ISO-8859-1" does not seem to be set. There are spanish characters in the file and upon opening the updated xm file in the browser, I get "Invalid character" errors for the spanish characters..

Is there an alternative method to set the encoding for the created "Content" object? Appreciate any pointers on this. Thanks!

~Prachi

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

resolved by creating content from the string "<?xml version="1.0" encoding="ISO-8859-1"?>" + rootElement.toString()