掲示板

Export Custom Table data to XML

8年前 に Mohamed Faisal によって更新されました。

Export Custom Table data to XML

Junior Member 投稿: 90 参加年月日: 09/08/12 最新の投稿
Hi all,

I would like to export custom table data to XML file.
While clicking Export button, a XML file containing custom table data(custom_table1, custom_table2 etc ) exported is downloaded in the browser.

The samplle XML format is:
<custom_table1>
<column_name1></column_name1>
<column_name2></column_name2>
......
</custom_table1>
<custom_table2>
<column_name1></column_name1>
<column_name2></column_name2>
......
<custom_table2>


Please let me know how to do this functionality.

Thanks & Regards,
Faisal
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Export Custom Table data to XML

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
How would you do it in a non-Liferay environment? Don't worry, it's a rhetorical question, I know the answer but am trying to figure out if you know it too.
8年前 に Mohamed Faisal によって更新されました。

RE: Export Custom Table data to XML

Junior Member 投稿: 90 参加年月日: 09/08/12 最新の投稿
Hi Nebinger,

I have not tried in non-Liferay environment. But we do it using DocumentBuilder, below is sample code

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("company");
doc.appendChild(rootElement);

then finally

StreamResult result = new StreamResult(new File("liferay.xml"));

I dont know that whether the above code will work or not?

Please let me know the answer.

Regards,
Faisal
thumbnail
8年前 に Jan Geißler によって更新されました。

RE: Export Custom Table data to XML

Liferay Master 投稿: 735 参加年月日: 11/07/05 最新の投稿
So if you don't mind me asking:
Why don't you try out before asking questions about things you haven't tried?
8年前 に Mohamed Faisal によって更新されました。

RE: Export Custom Table data to XML

Junior Member 投稿: 90 参加年月日: 09/08/12 最新の投稿
Hi Geißler,

Thank you for your suggestion. My question was that Is there any simple way using liferay API to achieve this?

Regards,
Faisal
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Export Custom Table data to XML

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
Mohamed Faisal:
I have not tried in non-Liferay environment. But we do it using DocumentBuilder, below is sample code

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("company");
doc.appendChild(rootElement);

then finally

StreamResult result = new StreamResult(new File("liferay.xml"));


Well there's nothing magical about the portal. Do the same thing on the portal side, but you build into a Resource request handler to serve the XML content back to the browser.
8年前 に Mohamed Faisal によって更新されました。

RE: Export Custom Table data to XML

Junior Member 投稿: 90 参加年月日: 09/08/12 最新の投稿
Thank you Nebinger.
I have done the functionality with your suggestion, but I have one clarification :
I need to export total five tables data, there are 75 columns to export. For each and every column I need to write the following three lines of code.

Element serviceUrl = doc.createElement("test");
test.appendChild(doc.createTextNode(testValue));
configuration.appendChild(test);

Then the code will be too big. Please suggest the way to reduce the code.

Thanks & Regards,
Faisal
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Export Custom Table data to XML

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
Mohamed Faisal:
I have done the functionality with your suggestion, but I have one clarification :
I need to export total five tables data, there are 75 columns to export. For each and every column I need to write the following three lines of code.

Element serviceUrl = doc.createElement("test");
test.appendChild(doc.createTextNode(testValue));
configuration.appendChild(test);

Then the code will be too big. Please suggest the way to reduce the code.


Personally I wouldn't be doing this at all. There's plenty of ORM and OXM tools to make this kind of thing possible.

But if you want to do it manually, reducing the code for the portal version is the same as reducing for the servlet version; if you can't reduce it there you won't be able to reduce it for the portal.
8年前 に Mohamed Faisal によって更新されました。

RE: Export Custom Table data to XML

Junior Member 投稿: 90 参加年月日: 09/08/12 最新の投稿
Hi Nebinger,

Thank you for your reply. I will check and do this.

Regards,
Faisal
8年前 に Harsh Joshi によって更新されました。

RE: Export Custom Table data to XML

Junior Member 投稿: 27 参加年月日: 15/01/28 最新の投稿
you can use Mule-ESB for esier access
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Export Custom Table data to XML

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
Mule ESB has nothing to do with OXM. It'd be like bringing a bag full of hammers to put a push pin into the wall.