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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:45:35+00:00 2026-06-03T20:45:35+00:00

I’m trying to populate an xml file into a Delphi ListView1, then group all

  • 0

I’m trying to populate an xml file into a Delphi ListView1, then “group” all the [items and subitems] by a [tag] defined in the xml file under the Category section,

I’m trying to make my program have a “tag” system so similar software will be grouped by a common tag, I’m open to suggestions if its not possible with listview then I can use other components to like VirtualStringTree, easylistview ..etc, this program is for my personal use, I’m just curious from a learning point of view since I have seen no other examples on how to accomplish this.

so for the xml listed below it should look like

ListView1
TAG1 [Each tag name in the category, this would be a group]
- New Item 1 <- Category name
   -Copy of File <- subitem software name
- bin [This is another category but it has TAG1 so group it with TAG1 items]
TAG4 [Each tag name in the category, this would be a group]
- New Item 1 <-this is the same as TAG1, add it to the TAG4 group since its in tags]
  -Copy of File <- subitem software of category

here is a sample of my xml file.

file.xml
<Category>
<Category name="New Item 1" Tags="TAG1 TAG4"/>
 <Software name="Copy of File" Tags="">
  <PathCache>data\cache\945.ico</PathCache>
  <PathExe>$Drive\Development\file.exe</PathExe>
 </Software>
<Category name="bin" Tags="TAG1">
 <Software name="Copy of File" Tags="">
  <PathCache>data\cache\947.ico</PathCache>
 <PathExe>$Drive\Development\file.exe</PathExe>
</Software>
<Software name="softwaretitle" Tags="">
    <PathCache>data\cache\946.ico</PathCache>
    <PathExe>$Drive\Development\test.exe</PathExe>
 </Software>
 </Category>
 </Category>

I added the tags=”” section to the Category section in the xml file, I can rewrite it if needed to

 <Category name="New Item 1"/>
  <Tags>Tag1 Tag4</tag>
  • 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-03T20:45:37+00:00Added an answer on June 3, 2026 at 8:45 pm

    First you should better organize your XML file, to at least this (I suggest you use Notepad++ to indent your XML):

    <Categories>
      <Category name="New Item 1" Tags="TAG1 TAG4">
        <Software name="Copy of File" Tags="">
          <PathCache>data\cache\945.ico</PathCache>
          <PathExe>$Drive\Development\file.exe</PathExe>
        </Software>
        <Software name="Copy of File" Tags="">
          <PathCache>data\cache\945.ico</PathCache>
          <PathExe>$Drive\Development\file.exe</PathExe>
        </Software>
      </Category>
      <Category name="bin" Tags="TAG1">
        <Software name="Copy of File" Tags="">
          <PathCache>data\cache\947.ico</PathCache>
          <PathExe>$Drive\Development\file.exe</PathExe>
        </Software>
        <Software name="softwaretitle" Tags="">
          <PathCache>data\cache\946.ico</PathCache>
          <PathExe>$Drive\Development\test.exe</PathExe>
        </Software>
      </Category>
    </Categories>
    

    After you have a normalized XML, you can convert it into Delphi classes using XMLDataBinding (File/New/Other/XML/XMLDataBinding), choosing your Categories.xml file.

    With the XML mapped to Delphi classes, you can easily walk through the XML data.

    Example (Delphi XE):

    type
      TForm1 = class(TForm)
        btnPopulate: TButton;
        lvCategories: TListView;
        procedure btnPopulateClick(Sender: TObject);
      private
        Categories: IXMLCategoriesType;
        procedure LoadCategories(const FileName: string);
        procedure PopulateCategoriesList;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.LoadCategories(const FileName: string);
    var
      XMLDoc1: TXMLDocument;
    begin
      if Assigned(Categories) then
        Exit;
    
      XMLDoc1 := TXMLDocument.Create(Self);
      XMLDoc1.FileName := FileName;
      XMLDoc1.Active := True;
      Categories := GetCategories(XMLDoc1);
    end;
    
    procedure TForm1.PopulateCategoriesList;
      i, j: Integer;
      Column: TListColumn;
      Group: TListGroup;
      Item: TListItem;
    begin
      lvCategories.ViewStyle := vsReport;
      lvCategories.GroupView := True;
      Column := lvCategories.Columns.Add;
      Column.Caption := 'Software name';
      Column.AutoSize := True;
    
      Column := lvCategories.Columns.Add;
      Column.Caption := 'Exe path';
      Column.AutoSize := True;
    
      for i := 0 to Categories.Count - 1do
      begin
        Group := lvCategories.Groups.Add;
        Group.Header := Copy(Categories.Category[i].Tags, 1, Pos(' ', Categories.Category[i].Tags) - 1);
        for j := 0  to Categories.Category[i].Count - 1 do
        begin
          Item := lvCategories.Items.Add;
          Item.Caption := Categories.Category[i].Software[j].Name;
          Item.GroupID := Group.GroupID;
          Item.SubItems.Add(Categories.Category[i].Software[j].PathExe)
        end;
      end;
    end;
    
    procedure TForm1.btnPopulateClick(Sender: TObject);
    begin
      LoadCategories(ExtractFilePath(Application.ExeName) + '..\..\Categories.xml');
      PopulateCategoriesList;
    end;
    

    Hope this helps you!

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

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and

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.