Solved

How to display only the data I need from a tag in an XML file to a listview?

Posted on 2003-11-30
4
197 Views
Last Modified: 2010-04-05
The delphi application I created is extracting data from tag <title> of an xml document and then displays the data extracted in a listview.

My problem is not how to display the extracted data. The problem is that some of the data contained in the <title> tag is not useful to me so I don't need it to be displayed in the listview.

E.g.    2-&gt;3            useful data
         2-&gt;4            useful data
         4                     not useful
         5                     not useful

The program is extracting this type of data in a listview. I don't want the integers e.g. 4,5 to be displayed and I want e.g.  2-&gt;3,   2-&gt;4 to be displayed.

Please can somebody show me how to write a routine that displays only the data I need

Thanks
0
Comment
Question by:Elmaz
4 Comments
 
LVL 2

Accepted Solution

by:
Tussin earned 65 total points
Comment Utility
use function strpos.

This is an example.

procedure TForm1.Button1Click(Sender: TObject);
begin
  if StrPos(PChar(Edit1.Text), '-&gt;') <> nil then
    ShowMessage('Substring found')
  else
    ShowMessage('Substring not found');
end;
0
 
LVL 1

Assisted Solution

by:roknjohn
roknjohn earned 65 total points
Comment Utility
What is the exact critera that determines if the data is of interest to you?  e.g. the data must contain the "&" character; or, the data should not be an integer value.

Then, build a test function for the data, such as:

function IsUseful(Data: string) : boolean;
begin
  Result := Pos('&',Data)>0;
end;

Then, either apply the test before the item is added to the ListView or iterate throught the list and delete the ones that fail the test.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now