Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
206 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 260 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 260 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

926 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