+ Start a Discussion

Parsing XML

I have setup a REST API on an external application. I'm trying to use it to display information in force.com.


The XML returned is similar to this

    <procedure id="201011201" distribution_centre_id="2" hospital_id="143" date_booked="2011-01-25 00:00:00">
        <procedure_sales id="9892" procedure_id="201011201" person_id="212">
        <procedure_surgeon id="9893" procedure_id="201011201" person_id="580">
    <procedure id="201012022" distribution_centre_id="2" hospital_id="152" date_booked="2011-01-12 00:00:00">
        <procedure_sales id="10042" procedure_id="201012022" person_id="199">
        <procedure_surgeon id="10043" procedure_id="201012022" person_id="1013">


I'm trying to get it to output this basic data in html something like this to start


<div><p>Procedure Id : 201011201</p><p>Surgeon Id : 9893</p></div>

<div><p>Procedure Id : 201012022</p><p>Surgeon Id : 10043</p></div>


On my page I have this


 <apex:outputText value="{!Procedures}" escape="false"/>


and in my controller I have this method


 public String getProcedures() {
        String procedureString = '';
        if (this.theXMLDom != null && this.theXMLDom.getElementsByTagName('procedure') != null) {
            XmlDom.Element[] procedures = this.theXMLDom.getElementsByTagName('procedure');
            if( procedures != null ) {
                procedureString =+ '<div>Procedures</div>';
                for( XmlDom.Element procedure : procedures ) {
                    procedureString =+ '.';
                    procedureString =+ procedure.getValue('id');
        return procedureString;


I was hoping that would give me this output



but I only get this



how can I loop though the xml nodes and to get at the data?


(I'm using the XMLDom class)


Thanks for any help.





I sorted this out.


My request call was not setup corectly


I was using




instead of



I'll have to read up on how to send and acceot header options properly