function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sapana WSapana W 

formatted xml

I want to generate a formatted xml output. Currently what am getting is as below:

620 SW 5th Avenue Suite 400 Portland, Oregon 97204United States 345 Shoreline Park Mountain View,CA USA USA

I want xml output as:

                       <Street>620 SW 5th Avenue Suite 400</Street>
                        <City>Portland</City>
                        <State>Oregon</State>
                        <PostalCode>97204</PostalCode>
                        <Country>USA</Country>

and so on..

Heres my code:

<apex:page StandardController="Account" recordSetVar="Accounts" contentType="text/xml" showHeader="true" sidebar="false" cache="false">
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<apex:repeat value="{!Accounts}" var="eachAccount" >    
    <Account id="{!eachAccount.id}" name="{!eachAccount.name}">
        
            <Address type="Billing">
                <Street><stri>{!eachAccount.billingStreet}</stri></Street>
                <City>{!eachAccount.billingCity}</City>
                <State>{!eachAccount.billingState}</State>
                <PostalCode>{!eachAccount.billingPostalCode}</PostalCode>
                <Country>{!eachAccount.billingCountry}</Country>
            </Address>        
      </Account>
</apex:repeat>
</response>
</apex:page>
Balaji Chowdary GarapatiBalaji Chowdary Garapati

@SFDC Developer:

Instead of "<" and ">" symbols use html characters "&lt;"  "&gt;" and use <br/> to break line at end of each line so that it looks as the desired output.



Hope this helps:

Thanks,
Sapana WSapana W
Hi Balaji,

Very thanks for your reply...
But I still get the same output...

2334 N. Michigan Avenue, Suite 1500 Chicago, IL 60601, USA

How to resolve this?

 
Sapana WSapana W
I got half the solution for this issue using   <![CDATA[]]>
Heres the code:

<apex:page StandardController="Account" contentType="text/xml" showHeader="true" sidebar="false" cache="false">
<?xml version="1.0" encoding="UTF-8" ?>

<response>

    <Enquiry id="{!Account.id}" name="{!Account.name}">
        
         <Address>
            
            <![CDATA[
             
          <Street>{!eachAccount.billingStreet}</Street>
          <city>{!eachAccount.billingCity}</City>
             ..
             ..
             ..         
           ]]>
           
          </Address>
        
   </Enquiry>
</response>
</apex:page>

The output is:


<Street>620 SW 5th Avenue Suite 400</Street><City>Chicago</City>..

But how to put them in seperate lines??? I used \n, <br/> ,&#x0a;,&#x0d; , but neither worked..

           
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@SFDC Developer:

Im not sure why you didnt get it! here is what i used:

<apex:repeat value="{!AccountList}" var="Account">


 &lt;Address&gt;   <br/>

 &lt;Name&gt; {!Account.Name}  &lt;Name&gt;<br/>

&lt;/Address&gt;<br/>

</apex:repeat>

For which i got:

User-added image



Hope this helps:

Thanks,
Balaji

 
Sapana WSapana W
Hi Balaji,

Could you paste your VF code here? I am still unable to get desired output.
Balaji Chowdary GarapatiBalaji Chowdary Garapati
Here is the page:
 
<apex:page controller="DemoOnXMLDisplayCntlr">


<apex:repeat value="{!AccountList}" var="Account">


 &lt;Address&gt;   <br/>

 &lt;Name&gt; {!Account.Name}  &lt;Name&gt;<br/>

&lt;/Address&gt;<br/>

</apex:repeat>
</apex:page>