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 8671999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:05:38+00:00 2026-06-12T19:05:38+00:00

i have used IXMLDocument in delphi to create an XML File, i need to

  • 0

i have used IXMLDocument in delphi to create an XML File, i need to access the text value on each of the nodes called Manufacturer and display the results in a TListBox when Button1 is Clicked.

Here is how i have created the XML File, this is called on FormCreate:

procedure TfrmMain.CreateXML;
var
  BikeXMLDoc: IXMLDocument;
  Root, Bike, Manufacturer, Model, Year, Ratio1, Ratio2, Ratio3, Ratio4, Ratio5,
  Ratio6, Ratio7, PriRatio: IXMLNode;
begin
  // Create XML Document for bikes.xml
  BikeXmlDoc := TXMLDocument.Create(nil);
  BikeXmlDoc.Active := True;
  BikeXmlDoc.Options := BikeXmlDoc.Options + [doNodeAutoIndent];
  BikeXmlDoc.Version := '1.0';

  // Create Document Root Element
  Root := BikeXmlDoc.CreateNode('Bikes');
  BikeXmlDoc.DocumentElement := Root;

  // Create First Bike Node
  Bike := BikeXmlDoc.CreateNode('Bike');

  // Add Required Elements with values for Honda Fireblade 2012
  Manufacturer := BikeXmlDoc.CreateNode('Manufacturer');
  Manufacturer.Text := 'Honda';
  Model := BikeXmlDoc.CreateNode('Model');
  Model.Text := 'Fireblade CBR1000';
  Year := BikeXmlDoc.CreateNode('Year');
  Year.Text := '2012';
  Ratio1 := BikeXmlDoc.CreateNode('Ratio1');
  Ratio1.Text := '2.286';
  Ratio2 := BikeXmlDoc.CreateNode('Ratio2');
  Ratio2.Text := '1.778';
  Ratio3 := BikeXmlDoc.CreateNode('Ratio3');
  Ratio3.Text := '1.500';
  Ratio4 := BikeXmlDoc.CreateNode('Ratio4');
  Ratio4.Text := '1.333';
  Ratio5 := BikeXmlDoc.CreateNode('Ratio5');
  Ratio5.Text := '1.214';
  Ratio6 := BikeXmlDoc.CreateNode('Ratio6');
  Ratio6.Text := '1.138';
  Ratio7 := BikeXmlDoc.CreateNode('Ratio7');
  PriRatio := BikeXmlDoc.CreateNode('PriRatio');
  PriRatio.Text := '1.717';

  // Add elements to XML File
  Root.ChildNodes.Add(Bike);
  Bike.ChildNodes.Add(Manufacturer);
  Bike.ChildNodes.Add(Model);
  Bike.ChildNodes.Add(Year);
  Bike.ChildNodes.Add(Ratio1);
  Bike.ChildNodes.Add(Ratio2);
  Bike.ChildNodes.Add(Ratio3);
  Bike.ChildNodes.Add(Ratio4);
  Bike.ChildNodes.Add(Ratio5);
  Bike.ChildNodes.Add(Ratio6);
  Bike.ChildNodes.Add(Ratio7);
  Bike.ChildNodes.Add(PriRatio);

  // Save the XML File
  //ShowMessage('XML File Created : ' + AppFileLocation + 'bikes.xml');
  BikeXmlDoc.SaveToFile(AppFileLocation+'bikes.xml');
  BikeXmlDoc.Active := False;
  BikeXmlDoc := nil;
end;

The code is repeated 4 more times adding 4 more elements to the XML File, i have not added the code here as i didnt think it was neccessary. The Finished XML File is this:

<?xml version="1.0"?>
<Bikes>
  <Bike>
    <Manufacturer>Honda</Manufacturer>
    <Model>Fireblade CBR1000</Model>
    <Year>2012</Year>
    <Ratio1>2.286</Ratio1>
    <Ratio2>1.778</Ratio2>
    <Ratio3>1.500</Ratio3>
    <Ratio4>1.333</Ratio4>
    <Ratio5>1.214</Ratio5>
    <Ratio6>1.138</Ratio6>
    <Ratio7/>
    <PriRatio>1.717</PriRatio>
  </Bike>
  <Bike>
    <Manufacturer>Kawasaki</Manufacturer>
    <Model>ZX6R 636</Model>
    <Year>2013</Year>
    <Ratio1>2.846</Ratio1>
    <Ratio2>2.200</Ratio2>
    <Ratio3>1.850</Ratio3>
    <Ratio4>1.600</Ratio4>
    <Ratio5>1.421</Ratio5>
    <Ratio6>1.300</Ratio6>
    <Ratio7/>
    <PriRatio>1.900</PriRatio>
  </Bike>
  <Bike>
    <Manufacturer>Suzuki</Manufacturer>
    <Model>GSXR1000</Model>
    <Year>2011</Year>
    <Ratio1>2.562</Ratio1>
    <Ratio2>2.052</Ratio2>
    <Ratio3>1.714</Ratio3>
    <Ratio4>1.500</Ratio4>
    <Ratio5>1.360</Ratio5>
    <Ratio6>1.269</Ratio6>
    <Ratio7/>
    <PriRatio>1.617</PriRatio>
  </Bike>
  <Bike>
    <Manufacturer>Triumph</Manufacturer>
    <Model>Daytona 675R</Model>
    <Year>2010</Year>
    <Ratio1>2.312</Ratio1>
    <Ratio2>1.857</Ratio2>
    <Ratio3>1.565</Ratio3>
    <Ratio4>1.350</Ratio4>
    <Ratio5>1.238</Ratio5>
    <Ratio6>1.136</Ratio6>
    <Ratio7/>
    <PriRatio>1.848</PriRatio>
  </Bike>
  <Bike>
    <Manufacturer>Yamaha</Manufacturer>
    <Model>YZF R1</Model>
    <Year>2013</Year>
    <Ratio1>2.533</Ratio1>
    <Ratio2>2.063</Ratio2>
    <Ratio3>1.762</Ratio3>
    <Ratio4>1.522</Ratio4>
    <Ratio5>1.364</Ratio5>
    <Ratio6>1.269</Ratio6>
    <Ratio7/>
    <PriRatio>1.512</PriRatio>
  </Bike>
</Bikes>

How can i make it so when Button1 is pressed the XML File is accessed again, and the text Value of each Manufacturer is listed in ListBox1.Items.

I have tried solutions involving XPath to select only a single node, but i need to be able to select all the nodes.

Thank you people.

  • 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-12T19:05:39+00:00Added an answer on June 12, 2026 at 7:05 pm

    It could be this way (it’s untested, written here using online Delphi reference, don’t have Delphi by hand now):

    uses
      XMLDoc, XMLIntf, XMLDOM;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: Integer;
      XMLDocument: IXMLDocument;
      DOMNodeList: IDOMNodeList;
      DOMNodeSelect: IDOMNodeSelect;    
    begin
      XMLDocument := LoadXMLDocument('c:\File.xml');
      if Assigned(XMLDocument) and 
        Supports(XMLDocument.DocumentElement.DOMNode, IDOMNodeSelect, DOMNodeSelect) then
      begin
        DOMNodeList := DOMNodeSelect.selectNodes('/Bikes/Bike/Manufacturer/text()');
        ListBox1.Items.BeginUpdate;
        try
          ListBox1.Items.Clear;
          for I := 0 to DOMNodeList.length - 1 do
            ListBox1.Items.Add(DOMNodeList.item[I].nodeValue);
        finally
          ListBox1.Items.EndUpdate;
        end;           
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service that is being used to generate an XML file
I have an XSD file and I want to create an XML file at
I have used Java, C++, .Net. (in that order). When asked about by-value vs.
i have an xml file that looks something like this <library> <book name=ABC> <chapter
I'm new to xml in .net, And I have this requirements that i need
I have a function that will will generate a dataset and create an xml
I have a web service which returns a string representing an Xml file. The
I have implemented a csv file builder that takes in an xml document applies
It's been long time I manipulated raw XML. I have used XmlDocument and remember
I am trying to create an XML file using string data. (Which is itself

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.