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
201 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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