Note that there are some explanatory texts on larger screens.

plurals
  1. POSalesforce consuming XML and display data in Visualforce report
    primarykey
    data
    text
    <p>Firstly, this question requires a bit of introduction so please bear with me. </p> <p>The high level is that I am connecting to a outside web service which will return some XML to my apex controller. The idea is that I want to display the XML returned into a nice tabular format in a VisualForce page. The format of the XML coming back will look something like this:</p> <pre><code>&lt;Wrapper&gt;&lt;reportTable name='table_id' title='Report Title'&gt; &lt;row&gt; &lt;Element1&gt;&lt;![CDATA[campaign_id]]&gt;&lt;/Element1&gt; &lt;Element2&gt;&lt;![CDATA[577373]]&gt;&lt;/Element2&gt; &lt;Element3&gt;&lt;![CDATA[4129]]&gt;&lt;/Element3&gt; &lt;Element4 dataFormat='2' dataSuffix='%'&gt;&lt;![CDATA[0.7151]]&gt;&lt;/Element4&gt; &lt;Element5&gt;&lt;![CDATA[2010-04-04]]&gt;&lt;/Element5&gt; &lt;Element6&gt;&lt;![CDATA[2010-05-03]]&gt;&lt;/Element6&gt; &lt;/row&gt; &lt;/reportTable&gt; </code></pre> <p>... </p> <p>Now currently I am using the XMLdom utility class (developed by SF for XML functions) to map this data into a custom object "reportTable" which contains a list of "row" custom objects. The reason I am building it out this way is because I don't know how many elements will be in each row, nor the number of rows.</p> <p>The Visualforce page looks something like this:</p> <pre><code>&lt;table&gt;&lt;apex:repeat value="{!reportTables}" var="table"&gt; &lt;apex:repeat value="{!table.rows}" var="row"&gt; &lt;tr&gt; &lt;apex:repeat value="{!row.ColumnValue}" var="column"&gt; &lt;apex:repeat value="{!column}" var="value"&gt; &lt;td&gt; &lt;apex:outputText value="{!value}" /&gt; &lt;/td&gt; &lt;/apex:repeat&gt; &lt;/apex:repeat&gt; &lt;/tr&gt; &lt;/apex:repeat&gt; </code></pre> <p> </p> <p>Questions are:</p> <p>1) Does this seem like a good approach to the problem?</p> <p>2) Is there a simpler/better way to consume the XML besides writing my own custom objects to map VF to?</p> <p>Open to any and all suggestions. I really hope there is a better way than building the HTML table myself, as then I also have to deal with styling and alignment etc. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload