Expand my Community achievements bar.

SOLVED

Render JSP as XML in component

Avatar

Level 5

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

4 Replies

Avatar

Level 9
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>

 

 

Avatar

Correct answer by
Level 10

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

Avatar

Level 5

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

Avatar

Level 4

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