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

  • SEARCH
  • Home
  • 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 8609863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:58:53+00:00 2026-06-12T03:58:53+00:00

i have used the delphi data binding wizard with my xml file, and everything

  • 0

i have used the delphi data binding wizard with my xml file, and everything compiles and runs fine.

I have 3 comboboxes on my form. Manufacturer, Model and Year.

Manufacturer is populated using the following code on FormCreate.

procedure TfrmMain.FormCreate(Sender: TObject);
var
  RGearing : IXMLracegearingType;
  i : Integer;
begin
  // Load XML Document into Memory
  RGearing := Getracegearing(XMLDocument1);

  // Populate Manufacturer combobox
  for i := 0 to RGearing.Car.Count-1 do
  begin
    cbManufac.Items.Add(RGearing.Car[i].Manufacturer);
  end;

  // Copy current selected Manufacturer to string variable
  varManufac := cbManufac.ListItems[(cbManufac.ItemIndex)].Text;
end;

My question is how can i populate the Model combobox based on the current manufacturer that is selected.

Here is the XML File that goes with it

<?xml version="1.0" encoding="UTF-8"?>
<gearing>
  <car>
    <id>1</id>
    <manufacturer>Ford</manufacturer>
    <model>Test 1</model>
    <year></year>
  </car>
  <car>
    <id>2</id>
    <manufacturer>Ford</manufacturer>
    <model>Test 2</model>
    <year></year>
  </car>
  <car>
    <id>3</id>
    <manufacturer>Honda</manufacturer>
    <model>Test 1</model>
    <year></year>   
  </car>
  <settings>
    <form_height></form_height>
    <form_width></form_width>
  </settings>
</gearing>

So if the manufacturer selected is Ford then the model combobox needs to display Test 1 and Test 2 as the items.

  • 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-12T03:58:55+00:00Added an answer on June 12, 2026 at 3:58 am

    I can not see your function and the type

    RGearing : IXMLracegearingType; 
    RGearing :=Getracegearing(XMLDocument1);
    

    So I can only test it with the following code.
    Go through the code and customize it to your needs.

    enter image description here

    unit xmlCombo;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        cbManufac: TComboBox;
        cbModel: TComboBox;
        procedure getManufac;
        procedure getModel(const ManufacVal:string);
        procedure FormActivate(Sender: TObject);
        procedure cbManufacClick(Sender: TObject);
      private
        { Private-Deklarationen }
      public
        { Public-Deklarationen }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    uses MSXML,ActiveX,ComObj;
    
    const
     XMLTestStr =
     '<?xml version="1.0" encoding="UTF-8"?>'+
     '<gearing>'+
     ' <car>'+
     '   <id>1</id>'+
     '   <manufacturer>Ford</manufacturer>'+
     '   <model>Test 1</model>'+
     '   <year></year>'+
     ' </car>'+
     ' <car>'+
     '   <id>2</id>'+
     '   <manufacturer>Ford</manufacturer>'+
     '   <model>Test 2</model>'+
     '   <year></year>'+
     ' </car>'+
     ' <car>'+
     '   <id>3</id>'+
     '   <manufacturer>Honda</manufacturer>'+
     '   <model>Test 1</model>'+
     '   <year></year>'+
     ' </car>'+
     ' <settings>'+
     '   <form_height></form_height>'+
     '   <form_width></form_width>'+
     ' </settings>'+
    '</gearing>';
    
    var
      varManufac : string;
      RGearing  : IXMLDOMDocument;
    
    procedure TForm1.cbManufacClick(Sender: TObject);
    begin
         getModel(cbManufac.Items[cbManufac.ItemIndex]);
    end;
    
    procedure TForm1.FormActivate(Sender: TObject);
    begin
      RGearing:=CoDOMDocument.Create;
      RGearing.loadXML(XmlTestStr);
      getManufac;
    end;
    
    procedure TForm1.getModel(const ManufacVal:string);
    Var
      XMLDOMNodeL  : IXMLDOMNodeList;
      ChildST : String;
      ChildN,BNode : IXMLDOMNode;
      i : Integer;
    
    begin
      cbModel.Items.Clear;
      cbModel.Text:='';
      XMLDOMNodeL:=RGearing.getElementsByTagName('car');
      for i := 0 to XMLDOMNodeL.length-1 do
      begin
        ChildN:=XMLDOMNodeL[i].selectSingleNode('manufacturer');
        if ChildN.text=ManufacVal then begin
           BNode:=XMLDOMNodeL[i].selectSingleNode('model');           
           ChildST:=BNode.text;
           if cbModel.Items.IndexOf(ChildST) = -1 then cbModel.Items.Add(ChildST);
        end;
      end;
    end;
    
    procedure TForm1.getManufac;
    Var
      XMLDOMNodeList  : IXMLDOMNodeList;
      ChildST : string;
      i : Integer;
    
    begin
      cbManufac.Items.Clear;
      cbManufac.Text:='';
      // Populate Manufacturer combobox
      XMLDOMNodeList:=RGearing.getElementsByTagName('manufacturer');
      for i := 0 to XMLDOMNodeList.length-1 do
      begin
        ChildST:=XMLDOMNodeList[i].text;
        if cbManufac.Items.IndexOf(ChildST) = -1 then cbManufac.Items.Add(ChildST);
        if cbManufac.Items.Count = 1 then begin
           cbManufac.Text:=ChildST;
           getModel(ChildST);
        end;
      end;
    end;
    
    end.
    

    To load xml from a file.

    if RGearing.Load('File.xml') then
      [...]
     else
      ShowMessage('Could not load file : File.xml');
    end;
    

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to using XML in Delphi, and have used the questions already
I have a Delphi 2010 DLL that will be used to compress some data
I have used the silverlight control in CRM 2011.It also published on form but
I have used a plugin that uses prototype js, it's working fine but the
I have two files, one with webservice description (wsdl), second with data structures used
We have a Delphi 2007 routine used to encrypt passwords in a table. The
I am using Delphi 2009. I have a very simple data structure, with 2
Using Delphi 2010, I have used TSQLQuery and TSQLConnection to connect to a remote
I have used TMS ribbon controls and ribbon controls came with Delphi 2009 in
We have used Shibboleth to authenticate users. It works great. The issue is that

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.