Render JSP as XML in component | Community
Skip to main content
Level 5
October 16, 2015
Solved

Render JSP as XML in component

  • October 16, 2015
  • 4 replies
  • 1648 views

Hi

I have component whose JSP has some xml and html tags. I drop the component on the page, I want on the disable mode it should display DOM tree like xml tags also able to expand and collapse tags same like we open xml in browser. Start from <html> . Any idea how can i achieve it.

<c:if test = "${! wcmMode}"> //disable mode //code </c:if>

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Another option you have when working with AEM and XML is to develop an AEM Service that returns XML and then have JS app logic parse that XML and set a control on the web page. We show this concept in this AEM community article - where a custom AEM service returns JCR data within XML and then XML is used to populate a grid control:

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

4 replies

Community Advisor
October 16, 2015
You might need to define conditional directive how you want to render your page
 

<c:if test = "${! wcmMode}">

 <%@ page contentType="text/xml" %>

//code

<?xml version="1.0" encoding="UTF-8"?> <portfolio> <stock> <symbol>SUNW</symbol> <name>Sun Microsystems</name> <price>17.1</price> </stock> <stock> <symbol>AOL</symbol> <name>America Online</name> <price>51.05</price> </stock> <stock> <symbol>IBM</symbol> <name>International Business Machines</name> <price>116.10</price> </stock> <stock> <symbol>MOT</symbol> <name>MOTOROLA</name> <price>15.20</price> </stock> </portfolio>

</c:if>

 

 
smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

Another option you have when working with AEM and XML is to develop an AEM Service that returns XML and then have JS app logic parse that XML and set a control on the web page. We show this concept in this AEM community article - where a custom AEM service returns JCR data within XML and then XML is used to populate a grid control:

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

vdhim23Author
Level 5
October 16, 2015

Mshajiahmed wrote...

You might need to define conditional directive how you want to render your page

<c:if test = "${! wcmMode}">

 <%@ page contentType="text/xml" %>

//code

<?xml version="1.0" encoding="UTF-8"?> <portfolio> <stock> <symbol>SUNW</symbol> <name>Sun Microsystems</name> <price>17.1</price> </stock> <stock> <symbol>AOL</symbol> <name>America Online</name> <price>51.05</price> </stock> <stock> <symbol>IBM</symbol> <name>International Business Machines</name> <price>116.10</price> </stock> <stock> <symbol>MOT</symbol> <name>MOTOROLA</name> <price>15.20</price> </stock> </portfolio>

</c:if>

 

 

 

Hi Thanks, I already written line 

<%@ page contentType="text/xml; charset=utf-8" import="com.day.cq.wcm.api.WCMMode" %>

nothing happens, Even i think its only for xml code but i am looking for whole DOM like in view source.

Something like in attached file, where i'll hit the page (which has my component) with wcmmode=disabled

vikramca06
Level 4
October 16, 2015

Hi,

In your component create a file named as books.xml.jsp and then

 <%@ page contentType="text/xml" %>

<books><book><name>Padam History</name><author>ZARA</author><price>100</price></book><book><name>Great Mistry</name><author>NUHA</author><price>2000</price></book></books>

just try this. it works.

if it is your page component then call it has path/pagename.books.xml.

if it is a normal component then path/pagename/jcr:content/parsys/compoent.books.xml