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
200 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
ID: 9848542
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
ID: 9851968
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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