Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:57:40+00:00 2026-06-13T21:57:40+00:00

I am making an external call to a Server and returning XML (HTTPResponse). I

  • 0

I am making an external call to a Server and returning XML (HTTPResponse). I then use a DOM parser to get a list of items.
How can I add the list of items to a DataTable/DataList?

How can I parse the XML structure into a Salesforce structure within the class itself?

Thank you

Hi eyesscream. All is working fine, except one thing. I needed to get deep in XML

Dom.XMLNode rootElement = doc.getRootElement();
for (Dom.XmlNode assets : rootElement.getChildElements()) {
    if (assets.getName().trim() == 'models') {
        for (Dom.XmlNode asset : assets.getChildElements()) {
            if (asset.getName().trim() == 'model') {
                for (Dom.XmlNode serial : asset.getChildElements()) {
                    if (serial.getName().trim() == 'modelNumber') {
                        text = serial.getText().trim();
                        allOptons.add(new SelectOption(text, text));
                    }
                }
            }
        }
    }
}

on VF page it duplicates the results. Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:57:42+00:00Added an answer on June 13, 2026 at 9:57 pm

    Go through your XML adding elements to a list of strings of wrapper objects if you need to store more than 1 parameter. Then such list can be assigned to dataTable, pageBlockTable, repeat etc tags without any problems. It’s not like these tags work only on standard sObjects.

    For a simple list of Strings with checkboxes you don’t even need any helper classes.

    public class StackXml{
        public List<SelectOption> allOptions {get;private set;}    // this will hold serial numbers for use in VF page.
        // if you wouldn't plan to use VF with checkboxes, simple List<String> would be enough
    
        public List<String> selectedOptions {get;set;}
    
        public StackXml(){
            allOptions = new List<SelectOption>();
            selectedOptions = new List<String>();
    
            String xmlString = '<serials><serialNumber>ver123</serialNumber><serialNumber>ver456 </serialNumber>' +
                '<intrusion>something to prove it will be skipped</intrusion>' +
                '<serialNumber>abc007</serialNumber></serials>';
    
            Dom.Document doc = new Dom.Document();
            doc.load(xmlString);
    
            Dom.XMLNode rootElement = doc.getRootElement();
            for(Dom.XmlNode node : rootElement.getChildElements()){
                if(node.getName().trim() == 'serialNumber') {
                    String text = node.getText().trim();
                    allOptions.add(new SelectOption(text, text));
                }
            }
        }
    
        public void assign(){}
    }
    

    <apex:page controller="StackXml">
        <apex:form>
            <apex:selectCheckboxes value="{!selectedOptions}" layout="pageDirection">
                <apex:selectOptions value="{!allOptions}"/>
            </apex:selectCheckboxes>
            <apex:commandButton value="Assign" action="{!assign}"/>
        </apex:form>
        <hr/>
        <p>You have selected:</p>
        <apex:dataList value="{!selectedOptions}" var="o">{!o}</apex:dataList>
    </apex:page>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an ajax request to an external php file, then returning some
I am making a simple AJAX call to an external site. It works ok
I can't get this to work even after making sure to set allowScriptAccess to
I'm making a call to an external service using the Zend Http client. The
I'm making a Phonegap app and need to retrieve some information from an external
Making an adobe flex ui in which data that is calculated must use proprietary
I'm making a program that displays some info in ncurses, and then opens vim
In ASP.Net MVC is it possible to use either Redirect or RedirectToAction to call
I've been trying to make an AJAX request to an external server. I've learned
I have a Java program that needs to call the same external executable 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.