PHP/Das XML-Projekt

Aus Mikiwiki
< PHP
Wechseln zu: Navigation, Suche

Grosse Praxisnähe war in den beiden vorangehenden Beispielen nicht zu erkennen - es ging mehr um die Vorführung der Funktionen. Das im folgenden gezeigte Projekt ist eine Erweiterung des Projekts "phpHoo" (siehe PHP/Suchmaschine). Richtig sinnvoll wird eine Suchmaschine erst, wenn genug Daten vorhanden sind - dafür gibt es etwa das Open Source-Projekt DMOZ. Zum Herunterladen kann die Seite http://rdf.dmoz.org/ aufgerufen werden. Das gesamte Projekt besteht aus zwei Teilen:

  • Eine leicht veränderte Fassung von "phpHoo".
  • Ein XML-Parser zum Import der Verzeichnisdaten.

Die XML-Daten selbst liegen in zwei Dateien vor, die sowohl die Struktur wie auch die Links enthalten. Der Parser durchsucht diese Dateien und überträgt die Inhalte in eine MySQL-Datenbank, auf welche die Anzeigefunktionen zugreifen.

Mit den untenstehenden Skripten kann das Projekt zwar zum Laufen gebracht werden... jedoch ohne dass es 100%-ig funktioniert. Grosse Lust, diese Skripte nach den Fehlern zu durchkämmen hab ich keine.

Datenbankstruktur

Zuerst muss eine Datenbank entworfen werden. Die beiden folgenden Definitionen zeigen, wie Struktur und Inhalt abgelegt werden.

Als erstes die Struktur des Verzeichnisses, die in der Tabelle "topic" gespeichert wird. Die Struktur realisiert einen B-Baum, bei dem jedes Element ("topic_id") einen Verweis auf ein übergeordnetes Element enthält ("topic_parent") und zugleich das Niveau oder die Ebene innerhalb des Baumes angegeben wird ("topic_level").

CREATE TABLE topic (
  id           int(11)      NOT NULL auto_increment,
  topic_id     int(11)      NOT NULL,
  topic_parent int(11)      NOT NULL,
  topic_title  varchar(255) NOT NULL,
  topic_level  tinyint(4)   NOT NULL,
  topic_desc   text,
  PRIMARY KEY (id),
  KEY topic_id (topic_id),
  KEY topic_parent (topic_parent),
  KEY topic_title (topic_title)
);

Die Indizes sind unbedingt notwendig, da das Verzeichnis sehr gross ist und ohne Indizierung unmöglich durchsucht werden kann. Der Inhalt wird in der Tabelle "content" abgelegt. Das Feld "topic_id" verweist auf das Feld "topic_id" in der Tabelle "topic".

CREATE TABLE content (
  id            int(11)      NOT NULL auto_increment,
  topic_id      int(11)      NOT NULL,
  content_page  varchar(255) NOT NULL,
  content_title varchar(255),
  content_desc  text,
  PRIMARY KEY (id),
  KEY topic_id (topic_id)
);

Die Datenquelle

Die Datenquelle ist eine RDF-Datei - die Anwendung als Datenspeicher für einen Katalog ist nur eine mögliche Anwendung.

Die folgende Datei zeigt, wie die erste Ebene definiert wird.

<!-- Name      structure.xml -->
<?xml version="1.0" encoding="utf-8" ?>
<RDF xmlns:r="http://www.w3.org/TR/RDF/"
     xmlns:d="http://purl.org/dc/elements/1.0/"
     xmlns  ="http://directory.mozilla.org/rdf">

<!-- Jede Ebene wird mit dem Element <Topic> definiert. Das Attribut "r:id" enthält den Namen. -->
<Topic r:id="Top">
  <!-- Jeder Eintrag enthält ausserdem eine eindeutige Katalog-ID (z. B. <tag catid="1"/>), die auch in der Datenbank genutzt wird. -->
  <tag catid="1"/>
  <!-- Es folgt ein beschreibender Titel, der auch zur Anzeige verwendet wird. -->
  <d:Title>Top</d:Title>
  <!-- Nun folgt eine Liste der Elemente, die unterhalb der Ebene stehen. -->
  <narrow r:resource="Top/Arts"/>
  <narrow r:resource="Top/Business"/>
  <narrow r:resource="Top/Computers"/>
  <narrow r:resource="Top/Games"/>
  <narrow r:resource="Top/Health"/>
  <narrow r:resource="Top/Home"/>
  <narrow r:resource="Top/News"/>
  <narrow r:resource="Top/Recreation"/>
  <narrow r:resource="Top/Reference"/>
  <narrow r:resource="Top/Regional"/>
  <narrow r:resource="Top/Science"/>
  <narrow r:resource="Top/Shopping"/>
  <narrow r:resource="Top/Society"/>
  <narrow r:resource="Top/Sports"/>
  <narrow r:resource="Top/Test"/>
  <narrow r:resource="Top/World"/>
  <narrow r:resource="Top/Private"/>
  <narrow r:resource="Top/Bookmarks"/>
</Topic>

<Topic r:id="Top/Arts">
  <tag catid="2"/>
  <d:Title>Arts</d:Title>
  <narrow r:resource="Top/Arts/Books"/>
  <narrow r:resource="Top/Arts/Music"/>
  <narrow r:resource="Top/Arts/Television"/>
  <narrow r:resource="Top/Arts/Writing"/>
  <narrow r:resource="Top/Arts/Animation"/>
  <narrow r:resource="Top/Arts/Anime"/>
  <narrow r:resource="Top/Arts/Bodyart"/>
  <narrow r:resource="Top/Arts/Bonsai"/>
  <narrow r:resource="Top/Arts/Comics"/>
  <narrow r:resource="Top/Arts/Dance"/>
  <narrow r:resource="Top/Arts/Fine_Arts"/>
  <narrow r:resource="Top/Arts/Muppets"/>
  <narrow r:resource="Top/Arts/Movies"/>
  <narrow r:resource="Top/Arts/Poetry"/>
  <narrow r:resource="Top/Arts/Theatre"/>
  <narrow r:resource="Top/Arts/Photography"/>
  <narrow r:resource="Top/Arts/Design"/>
  <narrow r:resource="Top/Arts/Radio"/>
  <narrow r:resource="Top/Arts/Online_Galleries"/>
  <narrow r:resource="Top/Arts/Digital"/>
  <narrow r:resource="Top/Arts/Graphic_Design"/>
  <narrow r:resource="Top/Arts/Storytelling"/>
  <narrow r:resource="Top/Arts/Publishing"/>
  <narrow r:resource="Top/Arts/Asian_Arts"/>
  <narrow r:resource="Top/Arts/Architecture"/>
  <narrow r:resource="Top/Arts/Decorative_Arts"/>
  <narrow r:resource="Top/Arts/Art_Directories_and_Links"/>
  <narrow r:resource="Top/Arts/Illustration"/>
  <narrow r:resource="Top/Arts/Magazines"/>
  <narrow r:resource="Top/Arts/Literature"/>
  <narrow r:resource="Top/Arts/Comedy"/>
  <narrow r:resource="Top/Arts/Art_Theft_and_Crime"/>
  <narrow r:resource="Top/Arts/Calligraphy"/>
  <narrow r:resource="Top/Arts/Museums"/>
  <narrow r:resource="Top/Arts/Art_History"/>
  <narrow r:resource="Top/Arts/People"/>
  <narrow r:resource="Top/Arts/Sculpture"/>
  <narrow r:resource="Top/Arts/Internet_Design"/>
  <narrow r:resource="Top/Arts/Ceramics"/>
  <narrow r:resource="Top/Arts/Video"/>
  <narrow r:resource="Top/Arts/Performing_Arts"/>
  <narrow r:resource="Top/Arts/ASCII"/>
  <narrow r:resource="Top/Arts/Artists"/>
  <!-- Neben Links zu tieferen Ebenen werden weitere Verweise gebildet. "<symbolic>" definiert Querverweise (in Yahoo werden diese durch das Zeichen "@" kenntlich gemacht.) -->
  <symbolic r:resource="Typography:Top/Computers/Fonts"/>
</Topic>

<Topic r:id="Top/Business">
  <tag catid="3"/>
  <d:Title>Business</d:Title>
  <narrow r:resource="Top/Business/Consulting"/>
  <narrow r:resource="Top/Business/Marketing"/>
  <narrow r:resource="Top/Business/Entrepreneurs"/>
  <narrow r:resource="Top/Business/Insurance"/>
  <narrow r:resource="Top/Business/Industries"/>
  <narrow r:resource="Top/Business/Investing"/>
  <narrow r:resource="Top/Business/Publications"/>
  <narrow r:resource="Top/Business/Jobs"/>
  <narrow r:resource="Top/Business/Advice"/>
  <narrow r:resource="Top/Business/Advertising"/>
  <narrow r:resource="Top/Business/Home_Business"/>
  <narrow r:resource="Top/Business/Management"/>
  <narrow r:resource="Top/Business/Classifieds"/>
  <narrow r:resource="Top/Business/Venture_Capital"/>
  <narrow r:resource="Top/Business/Books"/>
  <narrow r:resource="Top/Business/Accounting"/>
  <narrow r:resource="Top/Business/Financial_Services"/>
  <narrow r:resource="Top/Business/Manufacturing"/>
  <narrow r:resource="Top/Business/Business_Directories"/>
  <narrow r:resource="Top/Business/Training_and_Schools"/>
  <narrow r:resource="Top/Business/Business_Services"/>
  <narrow r:resource="Top/Business/International_Business_and_Trade"/>
  <narrow r:resource="Top/Business/Human_Resources"/>
  <narrow r:resource="Top/Business/Office_Services"/>
  <narrow r:resource="Top/Business/Real_Estate"/>
  <narrow r:resource="Top/Business/Opportunities"/>
  <narrow r:resource="Top/Business/Resources"/>
  <narrow r:resource="Top/Business/Office_Products"/>
  <symbolic r:resource="Transportation:Top/Business/Industries/Transportation"/>
  <symbolic r:resource="Retail:Top/Business/Industries/Retail"/>
  <symbolic r:resource="Internet:Top/Business/Industries/Information_Technology/Internet"/>
  <symbolic r:resource="Information Technology:Top/Business/Industries/Information_Technology"/>
  <symbolic r:resource="Legal:Top/Society/Law/Law_Firms"/>
  <symbolic r:resource="Travel:Top/Recreation/Travel"/>
</Topic>

<Topic r:id="Top/Computers">
  <tag catid="4"/>
  <d:Title>Computers</d:Title>
  <narrow r:resource="Top/Computers/Hacking"/>
  <narrow r:resource="Top/Computers/Graphics"/>
  <narrow r:resource="Top/Computers/CD_ROM"/>
  <narrow r:resource="Top/Computers/Internet"/>
  <narrow r:resource="Top/Computers/Security"/>
  <narrow r:resource="Top/Computers/Software"/>
  <narrow r:resource="Top/Computers/Hardware"/>
  <narrow r:resource="Top/Computers/Operating_Systems"/>
  <narrow r:resource="Top/Computers/Benchmarking"/>
  <narrow r:resource="Top/Computers/CAD"/>
  <narrow r:resource="Top/Computers/Algorithms"/>
  <narrow r:resource="Top/Computers/Databases"/>
  <narrow r:resource="Top/Computers/Data_Communications"/>
  <narrow r:resource="Top/Computers/DSP"/>
  <narrow r:resource="Top/Computers/Emulators"/>
  <narrow r:resource="Top/Computers/Fonts"/>
  <narrow r:resource="Top/Computers/Groupware"/>
  <narrow r:resource="Top/Computers/Home_Automation"/>
  <narrow r:resource="Top/Computers/Human_Factors"/>
  <narrow r:resource="Top/Computers/Multimedia"/>
  <narrow r:resource="Top/Computers/Programming"/>
  <narrow r:resource="Top/Computers/Robotics"/>
  <narrow r:resource="Top/Computers/Systems"/>
  <narrow r:resource="Top/Computers/Desktop_Publishing"/>
  <narrow r:resource="Top/Computers/Supercomputing"/>
  <narrow r:resource="Top/Computers/Jobs"/>
  <narrow r:resource="Top/Computers/Parallel_Computing"/>
  <narrow r:resource="Top/Computers/Bulletin_Board_Systems"/>
  <narrow r:resource="Top/Computers/Consultants"/>
  <narrow r:resource="Top/Computers/Vendors"/>
  <narrow r:resource="Top/Computers/Mobile_Computing"/>
  <narrow r:resource="Top/Computers/Companies"/>
  <narrow r:resource="Top/Computers/Learning"/>
  <narrow r:resource="Top/Computers/News"/>
  <narrow r:resource="Top/Computers/Organizations"/>
  <narrow r:resource="Top/Computers/Intranets"/>
  <narrow r:resource="Top/Computers/Artificial_Intelligence"/>
  <!-- Newsgroups, die keine weiteren Elemente enthalten können, werden ebenfalls direkt definiert. -->
  <newsGroup r:resource="news:comp.misc"/>
</Topic>

<Topic r:id="Top/Games">
  <tag catid="5"/>
  <d:Title>Games</d:Title>
  <narrow r:resource="Top/Games/MUDs"/>
  <narrow r:resource="Top/Games/Conventions"/>
  <narrow r:resource="Top/Games/Gambling"/>
  <narrow r:resource="Top/Games/Women-in-Gaming"/>
  <narrow r:resource="Top/Games/Video_Games"/>
  <narrow r:resource="Top/Games/Play_by_Mail"/>
  <narrow r:resource="Top/Games/Corewar"/>
  <narrow r:resource="Top/Games/Game_Design"/>
  <narrow r:resource="Top/Games/Miniatures"/>
  <narrow r:resource="Top/Games/Netrek"/>
  <narrow r:resource="Top/Games/Pinball"/>
  <narrow r:resource="Top/Games/Trading_Cards"/>
  <narrow r:resource="Top/Games/Puzzles"/>
  <narrow r:resource="Top/Games/Crossword_Puzzles"/>
  <narrow r:resource="Top/Games/Webgames"/>
  <narrow r:resource="Top/Games/IRC"/>
  <narrow r:resource="Top/Games/Game_Creation_Systems"/>
  <narrow r:resource="Top/Games/Fantasy_Sports"/>
  <narrow r:resource="Top/Games/Miscellaneous_Games"/>
  <narrow r:resource="Top/Games/Glass_Bead_Games"/>
  <narrow r:resource="Top/Games/Rogue-like"/>
  <narrow r:resource="Top/Games/Board_Games"/>
  <narrow r:resource="Top/Games/Card_Games"/>
  <narrow r:resource="Top/Games/Role-Playing_Games"/>
  <symbolic r:resource="Console Games:Top/Games/Video_Games/Console_Platforms"/>
  <symbolic r:resource="Interactive Fiction:Top/Games/Video_Games/Interactive_Fiction"/>
  <symbolic r:resource="Sports:Top/Sports"/>
  <symbolic r:resource="Programming:Top/Computers/Programming/Games"/>
  <symbolic r:resource="Computer Games:Top/Games/Video_Games/Computer_Platforms"/>
  <symbolic r:resource="Arcade Games:Top/Games/Video_Games/Arcade_Games"/>
  <newsGroup r:resource="news:rec.games.misc"/>
</Topic>

<Topic r:id="Top/Health">
  <tag catid="6"/>
  <d:Title>Health</d:Title>
  <narrow r:resource="Top/Health/Emergency_Services"/>
  <narrow r:resource="Top/Health/Fitness"/>
  <narrow r:resource="Top/Health/Pharmacy"/>
  <narrow r:resource="Top/Health/Alternative"/>
  <narrow r:resource="Top/Health/Life_Extension"/>
  <narrow r:resource="Top/Health/Medicine"/>
  <narrow r:resource="Top/Health/Dentistry"/>
  <narrow r:resource="Top/Health/Nursing"/>
  <narrow r:resource="Top/Health/Nutrition"/>
  <narrow r:resource="Top/Health/Vision"/>
  <narrow r:resource="Top/Health/Services"/>
  <narrow r:resource="Top/Health/Beauty"/>
  <narrow r:resource="Top/Health/Substance_Abuse"/>
  <narrow r:resource="Top/Health/Patient_Education"/>
  <narrow r:resource="Top/Health/Womens_Health"/>
  <narrow r:resource="Top/Health/Children"/>
  <narrow r:resource="Top/Health/Conditions"/>
  <narrow r:resource="Top/Health/Occupational_Health_and_Safety"/>
  <narrow r:resource="Top/Health/Mental_Health"/>
  <narrow r:resource="Top/Health/Aging"/>
  <narrow r:resource="Top/Health/Healthcare_Industry"/>
  <narrow r:resource="Top/Health/Products"/>
  <narrow r:resource="Top/Health/Publications"/>
  <narrow r:resource="Top/Health/Education"/>
  <narrow r:resource="Top/Health/Men's_Health"/>
  <narrow r:resource="Top/Health/Consumer_Support_Groups"/>
  <narrow r:resource="Top/Health/Disabilities"/>
  <narrow r:resource="Top/Health/Organizations"/>
  <narrow r:resource="Top/Health/Chat,_Discussion,_ICQ"/>
  <narrow r:resource="Top/Health/References_and_Resources"/>
  <narrow r:resource="Top/Health/Conditions_and_Diseases"/>
  <related r:resource="Top/Business/Industries/Health_and_Fitness"/>
  <related r:resource="Top/Computers/Internet/WWW/Directories/webring.org/Health"/>
  <related r:resource="Top/Society/Issues/Health_Care"/>
  <symbolic r:resource="Support Groups:Top/Society/Support_Groups"/>
  <newsGroup r:resource="news:alt.health"/>
</Topic>

<Topic r:id="Top/Home">
  <tag catid="7"/>
  <d:Title>Home</d:Title>
  <narrow r:resource="Top/Home/Consumers"/>
  <narrow r:resource="Top/Home/Houses"/>
  <narrow r:resource="Top/Home/Homeowners_Associations"/>
  <narrow r:resource="Top/Home/Financial_Planning"/>
  <narrow r:resource="Top/Home/Kids"/>
  <narrow r:resource="Top/Home/Rural"/>
  <narrow r:resource="Top/Home/Gardens"/>
  <narrow r:resource="Top/Home/Homemaking"/>
  <narrow r:resource="Top/Home/Tax_Preparation"/>
  <narrow r:resource="Top/Home/Recipes"/>
  <narrow r:resource="Top/Home/Entertainment"/>
</Topic>

<Topic r:id="Top/News">
  <tag catid="8"/>
  <d:Title>News</d:Title>
  <narrow r:resource="Top/News/Internet"/>
  <narrow r:resource="Top/News/Online"/>
  <narrow r:resource="Top/News/Media"/>
  <narrow r:resource="Top/News/Newspapers"/>
  <narrow r:resource="Top/News/Colleges_and_Universities"/>
  <narrow r:resource="Top/News/Magazines"/>
  <narrow r:resource="Top/News/News_Indexes"/>
  <narrow r:resource="Top/News/Weather"/>
  <narrow r:resource="Top/News/Filters"/>
  <narrow r:resource="Top/News/Columnists"/>
  <narrow r:resource="Top/News/Regional"/>
  <narrow r:resource="Top/News/Services"/>
  <narrow r:resource="Top/News/Tech_News"/>
  <symbolic r:resource="TV Industry News:Top/Arts/Television/Industry_News"/>
  <symbolic r:resource="Business News:Top/News/Online/Business_News"/>
  <symbolic r:resource="Political News:Top/News/Online/Political"/>
  <symbolic r:resource="Scientific News:Top/Science/Journals_and_Magazines/News"/>
  <symbolic r:resource="Radio:Top/Arts/Radio"/>
</Topic>

<Topic r:id="Top/Recreation">
  <tag catid="9"/>
  <d:Title>Recreation</d:Title>
  <narrow r:resource="Top/Recreation/Food"/>
  <narrow r:resource="Top/Recreation/Outdoors"/>
  <narrow r:resource="Top/Recreation/Antiques"/>
  <narrow r:resource="Top/Recreation/Aquaria"/>
  <narrow r:resource="Top/Recreation/Theme_Parks"/>
  <narrow r:resource="Top/Recreation/Autos"/>
  <narrow r:resource="Top/Recreation/Aviation"/>
  <narrow r:resource="Top/Recreation/Birdwatching"/>
  <narrow r:resource="Top/Recreation/Boating"/>
  <narrow r:resource="Top/Recreation/Climbing"/>
  <narrow r:resource="Top/Recreation/Collecting"/>
  <narrow r:resource="Top/Recreation/Crafts"/>
  <narrow r:resource="Top/Recreation/Drugs"/>
  <narrow r:resource="Top/Recreation/Guns"/>
  <narrow r:resource="Top/Recreation/Humor"/>
  <narrow r:resource="Top/Recreation/Kites"/>
  <narrow r:resource="Top/Recreation/Knives"/>
  <narrow r:resource="Top/Recreation/Models"/>
  <narrow r:resource="Top/Recreation/Motorcycles"/>
  <narrow r:resource="Top/Recreation/Nudism"/>
  <narrow r:resource="Top/Recreation/Pets"/>
  <narrow r:resource="Top/Recreation/Ponds"/>
  <narrow r:resource="Top/Recreation/Scouting"/>
  <narrow r:resource="Top/Recreation/Travel"/>
  <narrow r:resource="Top/Recreation/Zoological"/>
  <narrow r:resource="Top/Recreation/Smoking"/>
  <narrow r:resource="Top/Recreation/Hot_Air_Ballooning"/>
  <narrow r:resource="Top/Recreation/Acrobatics"/>
  <narrow r:resource="Top/Recreation/Amateur_Radio"/>
  <narrow r:resource="Top/Recreation/Trains_and_Railroads"/>
  <symbolic r:resource="Reading:Top/Arts/Books"/>
  <symbolic r:resource="Sports:Top/Sports"/>
  <symbolic r:resource="Gardens:Top/Home/Gardens"/>
  <symbolic r:resource="Games:Top/Games"/>
</Topic>

<Topic r:id="Top/Reference">
  <tag catid="10"/>
  <d:Title>Reference</d:Title>
  <narrow r:resource="Top/Reference/Education"/>
  <narrow r:resource="Top/Reference/Libraries"/>
  <narrow r:resource="Top/Reference/Maps"/>
  <narrow r:resource="Top/Reference/Archives"/>
  <narrow r:resource="Top/Reference/Lexicon"/>
  <narrow r:resource="Top/Reference/Dictionaries"/>
  <narrow r:resource="Top/Reference/Style_Guides"/>
  <narrow r:resource="Top/Reference/Directories"/>
  <narrow r:resource="Top/Reference/Encyclopedia"/>
  <narrow r:resource="Top/Reference/Quotations"/>
  <narrow r:resource="Top/Reference/Thesauri"/>
  <narrow r:resource="Top/Reference/Bibliography"/>
  <narrow r:resource="Top/Reference/Knowledge_Management"/>
  <narrow r:resource="Top/Reference/Handbooks"/>
  <narrow r:resource="Top/Reference/Parliamentary_Procedure"/>
</Topic>

<Topic r:id="Top/Regional">
  <tag catid="11"/>
  <d:Title>Regional</d:Title>
  <narrow r:resource="Top/Regional/NZ"/>
  <narrow r:resource="Top/Regional/US"/>
  <narrow r:resource="Top/Regional/Canada"/>
  <narrow r:resource="Top/Regional/UK"/>
  <narrow r:resource="Top/Regional/Europe"/>
  <narrow r:resource="Top/Regional/Australia"/>
  <narrow r:resource="Top/Regional/Asia"/>
  <narrow r:resource="Top/Regional/Africa"/>
  <narrow r:resource="Top/Regional/Middle_East"/>
  <narrow r:resource="Top/Regional/South_America"/>
  <narrow r:resource="Top/Regional/Central_America"/>
  <narrow r:resource="Top/Regional/Polar_Regions"/>
  <narrow r:resource="Top/Regional/Atlantic_Islands"/>
  <narrow r:resource="Top/Regional/Pacific_Islands"/>
  <narrow r:resource="Top/Regional/Indian_Ocean_Islands"/>
  <narrow r:resource="Top/Regional/Caribbean"/>
  <narrow r:resource="Top/Regional/North_America"/>
  <narrow r:resource="Top/Regional/A"/>
  <narrow r:resource="Top/Regional/B"/>
  <narrow r:resource="Top/Regional/C"/>
  <narrow r:resource="Top/Regional/D"/>
  <narrow r:resource="Top/Regional/E"/>
  <narrow r:resource="Top/Regional/F"/>
  <narrow r:resource="Top/Regional/L"/>
  <narrow r:resource="Top/Regional/Z"/>
  <narrow r:resource="Top/Regional/G"/>
  <narrow r:resource="Top/Regional/N"/>
  <narrow r:resource="Top/Regional/K"/>
  <narrow r:resource="Top/Regional/M"/>
  <narrow r:resource="Top/Regional/W"/>
  <narrow r:resource="Top/Regional/R"/>
  <narrow r:resource="Top/Regional/S"/>
  <narrow r:resource="Top/Regional/I"/>
  <narrow r:resource="Top/Regional/P"/>
  <narrow r:resource="Top/Regional/U"/>
  <narrow r:resource="Top/Regional/J"/>
  <narrow r:resource="Top/Regional/Q"/>
  <narrow r:resource="Top/Regional/T"/>
  <narrow r:resource="Top/Regional/H"/>
  <narrow r:resource="Top/Regional/Y"/>
  <narrow r:resource="Top/Regional/V"/>
  <narrow r:resource="Top/Regional/O"/>
  <related r:resource="Top/World"/>
</Topic>

<Topic r:id="Top/Science">
  <tag catid="12"/>
  <d:Title>Science</d:Title>
  <narrow r:resource="Top/Science/Psychology"/>
  <narrow r:resource="Top/Science/Pyrotechnics"/>
  <narrow r:resource="Top/Science/Aeronautics"/>
  <narrow r:resource="Top/Science/Agriculture"/>
  <narrow r:resource="Top/Science/Archaeology"/>
  <narrow r:resource="Top/Science/Astronomy"/>
  <narrow r:resource="Top/Science/Futurism"/>
  <narrow r:resource="Top/Science/Ecology"/>
  <narrow r:resource="Top/Science/Evolution"/>
  <narrow r:resource="Top/Science/Paleontology"/>
  <narrow r:resource="Top/Science/Regional"/>
  <narrow r:resource="Top/Science/Chemistry"/>
  <narrow r:resource="Top/Science/Cognitive_Science"/>
  <narrow r:resource="Top/Science/Cryonics"/>
  <narrow r:resource="Top/Science/Cryptography"/>
  <narrow r:resource="Top/Science/Economics"/>
  <narrow r:resource="Top/Science/Electronics"/>
  <narrow r:resource="Top/Science/Energy"/>
  <narrow r:resource="Top/Science/Engineering"/>
  <narrow r:resource="Top/Science/Environment"/>
  <narrow r:resource="Top/Science/Math"/>
  <narrow r:resource="Top/Science/Geology"/>
  <narrow r:resource="Top/Science/Meteorology"/>
  <narrow r:resource="Top/Science/Navigation"/>
  <narrow r:resource="Top/Science/Language_and_Linguistics"/>
  <narrow r:resource="Top/Science/Logic"/>
  <narrow r:resource="Top/Science/Materials"/>
  <narrow r:resource="Top/Science/Laboratory_Medicine"/>
  <narrow r:resource="Top/Science/Military"/>
  <narrow r:resource="Top/Science/Optics"/>
  <narrow r:resource="Top/Science/Physics"/>
  <narrow r:resource="Top/Science/Polymers"/>
  <narrow r:resource="Top/Science/Skeptics"/>
  <narrow r:resource="Top/Science/Space"/>
  <narrow r:resource="Top/Science/Statistics"/>
  <narrow r:resource="Top/Science/Biology"/>
  <narrow r:resource="Top/Science/Physiology"/>
  <narrow r:resource="Top/Science/Software"/>
  <narrow r:resource="Top/Science/Geomatics"/>
  <narrow r:resource="Top/Science/Ethnology"/>
  <narrow r:resource="Top/Science/Molecular_Biology"/>
  <narrow r:resource="Top/Science/Immunology"/>
  <narrow r:resource="Top/Science/Food_Science"/>
  <narrow r:resource="Top/Science/Forensic"/>
  <narrow r:resource="Top/Science/FAQs"/>
  <narrow r:resource="Top/Science/Sociology"/>
  <narrow r:resource="Top/Science/Biochemistry"/>
  <narrow r:resource="Top/Science/Anomalies"/>
  <narrow r:resource="Top/Science/Cryptozoology"/>
  <narrow r:resource="Top/Science/Acoustics,_Noise_and_Vibration"/>
  <narrow r:resource="Top/Science/Oceanography"/>
  <narrow r:resource="Top/Science/Nanotechnology"/>
  <narrow r:resource="Top/Science/Crystallography"/>
  <narrow r:resource="Top/Science/About_Science"/>
  <narrow r:resource="Top/Science/Instruments_and_Supplies"/>
  <narrow r:resource="Top/Science/Political_Science"/>
  <narrow r:resource="Top/Science/Academia_and_Society"/>
  <narrow r:resource="Top/Science/About_Science_in_other_languages"/>
  <narrow r:resource="Top/Science/Journals_and_Magazines"/>
  <narrow r:resource="Top/Science/Museums"/>
  <narrow r:resource="Top/Science/A"/>
  <narrow r:resource="Top/Science/B"/>
  <narrow r:resource="Top/Science/C"/>
  <narrow r:resource="Top/Science/D"/>
  <narrow r:resource="Top/Science/E"/>
  <narrow r:resource="Top/Science/F"/>
  <narrow r:resource="Top/Science/G"/>
  <narrow r:resource="Top/Science/N"/>
  <narrow r:resource="Top/Science/V"/>
  <narrow r:resource="Top/Science/S"/>
  <narrow r:resource="Top/Science/M"/>
  <narrow r:resource="Top/Science/I"/>
  <narrow r:resource="Top/Science/P"/>
  <narrow r:resource="Top/Science/U"/>
  <narrow r:resource="Top/Science/O"/>
  <narrow r:resource="Top/Science/Physical_Sciences"/>
  <narrow r:resource="Top/Science/Fluid_Mechanics_and_Dynamics"/>
  <narrow r:resource="Top/Science/Z"/>
  <narrow r:resource="Top/Science/H"/>
  <narrow r:resource="Top/Science/R"/>
  <narrow r:resource="Top/Science/T"/>
  <narrow r:resource="Top/Science/X"/>
  <narrow r:resource="Top/Science/L"/>
  <narrow r:resource="Top/Science/W"/>
  <narrow r:resource="Top/Science/Q"/>
  <narrow r:resource="Top/Science/Science-Technology_Policy"/>
  <related r:resource="Top/Reference/Encyclopedia"/>
  <symbolic r:resource="History of Science:Top/Society/History/Science"/>
  <symbolic r:resource="Hydrology:Top/Science/Environment/Water_Resources"/>
  <symbolic r:resource="History:Top/Society/History"/>
  <symbolic r:resource="Anthropology:Top/Science/Biology/Anthropology"/>
  <symbolic r:resource="Universities:Top/Reference/Education/Colleges_and_Universities"/>
  <symbolic r:resource="Education:Top/Reference/Education/Science"/>
  <symbolic r:resource="Medicine:Top/Health/Medicine"/>
  <symbolic r:resource="Philosophy:Top/Society/Philosophy"/>
  <newsGroup r:resource="news:sci.misc"/>
</Topic>

<Topic r:id="Top/Shopping">
  <tag catid="13"/>
  <d:Title>Shopping</d:Title>
  <narrow r:resource="Top/Shopping/Autos"/>
  <narrow r:resource="Top/Shopping/Clothing"/>
  <narrow r:resource="Top/Shopping/Directories"/>
  <narrow r:resource="Top/Shopping/Online_Auctions"/>
  <narrow r:resource="Top/Shopping/Books"/>
  <narrow r:resource="Top/Shopping/Miscellaneous"/>
  <narrow r:resource="Top/Shopping/Gifts"/>
  <narrow r:resource="Top/Shopping/Music"/>
  <narrow r:resource="Top/Shopping/Jewelry"/>
  <narrow r:resource="Top/Shopping/Online_Malls"/>
  <narrow r:resource="Top/Shopping/Crafts"/>
  <narrow r:resource="Top/Shopping/Home_and_Garden"/>
  <narrow r:resource="Top/Shopping/International"/>
  <narrow r:resource="Top/Shopping/Pets"/>
  <narrow r:resource="Top/Shopping/Health_and_Beauty"/>
  <narrow r:resource="Top/Shopping/Computers"/>
  <narrow r:resource="Top/Shopping/Food"/>
  <narrow r:resource="Top/Shopping/Home_Electronics"/>
  <narrow r:resource="Top/Shopping/Children"/>
  <narrow r:resource="Top/Shopping/Antiques_and_Collectables"/>
  <narrow r:resource="Top/Shopping/Art_Galleries"/>
  <narrow r:resource="Top/Shopping/Office_Supplies"/>
  <narrow r:resource="Top/Shopping/Sporting_Goods"/>
  <narrow r:resource="Top/Shopping/Party_Supplies"/>
  <narrow r:resource="Top/Shopping/Housewares"/>
  <narrow r:resource="Top/Shopping/Flowers"/>
  <narrow r:resource="Top/Shopping/Videos"/>
  <narrow r:resource="Top/Shopping/Hardware_-_Home_Improvement"/>
  <narrow r:resource="Top/Shopping/General_Merchandise"/>
  <symbolic r:resource="Furniture:Top/Shopping/Home_and_Garden/Furniture"/>
</Topic>

<Topic r:id="Top/Society">
  <tag catid="14"/>
  <d:Title>Society</d:Title>
  <narrow r:resource="Top/Society/Activism"/>
  <narrow r:resource="Top/Society/Heraldry"/>
  <narrow r:resource="Top/Society/Subcultures"/>
  <narrow r:resource="Top/Society/Death"/>
  <narrow r:resource="Top/Society/Future"/>
  <narrow r:resource="Top/Society/Genealogy"/>
  <narrow r:resource="Top/Society/History"/>
  <narrow r:resource="Top/Society/Men"/>
  <narrow r:resource="Top/Society/Transgendered"/>
  <narrow r:resource="Top/Society/Advice"/>
  <narrow r:resource="Top/Society/Military"/>
  <narrow r:resource="Top/Society/People"/>
  <narrow r:resource="Top/Society/Religion"/>
  <narrow r:resource="Top/Society/Human_Rights"/>
  <narrow r:resource="Top/Society/Support_Groups"/>
  <narrow r:resource="Top/Society/Women"/>
  <narrow r:resource="Top/Society/Law"/>
  <narrow r:resource="Top/Society/Paranormal"/>
  <narrow r:resource="Top/Society/Issues"/>
  <narrow r:resource="Top/Society/Politics"/>
  <narrow r:resource="Top/Society/Holidays"/>
  <narrow r:resource="Top/Society/Sexuality"/>
  <narrow r:resource="Top/Society/Relationships"/>
  <narrow r:resource="Top/Society/Disabled"/>
  <narrow r:resource="Top/Society/Gay,_Lesbian,_and_Bisexual"/>
  <narrow r:resource="Top/Society/Organizations"/>
  <narrow r:resource="Top/Society/Ethnicity"/>
  <narrow r:resource="Top/Society/Indigenous_People"/>
  <narrow r:resource="Top/Society/Government"/>
  <narrow r:resource="Top/Society/Philosophy"/>
  <narrow r:resource="Top/Society/Lifestyle_Choices"/>
  <narrow r:resource="Top/Society/Seniors"/>
  <narrow r:resource="Top/Society/Urban_Legends"/>
  <symbolic r:resource="Crime:Top/Society/Law/Crime_and_Criminal_Law"/>
  <symbolic r:resource="Veterans:Top/Society/Military/Veterans"/>
  <symbolic r:resource="Editors' Picks:Top/Society/People/Editors_Picks"/>
  <symbolic r:resource="Education:Top/Reference/Education"/>
  <symbolic r:resource="Language and Linguistics:Top/Science/Language_and_Linguistics"/>
  <newsGroup r:resource="news:soc.misc"/>
</Topic>

<Topic r:id="Top/Sports">
  <tag catid="15"/>
  <d:Title>Sports</d:Title>
  <narrow r:resource="Top/Sports/Marching"/>
  <narrow r:resource="Top/Sports/Auto_Racing"/>
  <narrow r:resource="Top/Sports/Bicycling"/>
  <narrow r:resource="Top/Sports/Equestrian"/>
  <narrow r:resource="Top/Sports/Hunting"/>
  <narrow r:resource="Top/Sports/Juggling"/>
  <narrow r:resource="Top/Sports/Martial_Arts"/>
  <narrow r:resource="Top/Sports/Motorcycle_Racing"/>
  <narrow r:resource="Top/Sports/Scuba_Diving"/>
  <narrow r:resource="Top/Sports/Skiing"/>
  <narrow r:resource="Top/Sports/Snowboarding"/>
  <narrow r:resource="Top/Sports/Skydiving"/>
  <narrow r:resource="Top/Sports/Archery"/>
  <narrow r:resource="Top/Sports/Baseball"/>
  <narrow r:resource="Top/Sports/Basketball"/>
  <narrow r:resource="Top/Sports/Billiards"/>
  <narrow r:resource="Top/Sports/Boxing"/>
  <narrow r:resource="Top/Sports/Cricket"/>
  <narrow r:resource="Top/Sports/Fencing"/>
  <narrow r:resource="Top/Sports/Football"/>
  <narrow r:resource="Top/Sports/Golf"/>
  <narrow r:resource="Top/Sports/Hockey"/>
  <narrow r:resource="Top/Sports/Bowling"/>
  <narrow r:resource="Top/Sports/Officiating"/>
  <narrow r:resource="Top/Sports/Olympics"/>
  <narrow r:resource="Top/Sports/Paintball"/>
  <narrow r:resource="Top/Sports/Pro_Wrestling"/>
  <narrow r:resource="Top/Sports/Rodeo"/>
  <narrow r:resource="Top/Sports/Rowing"/>
  <narrow r:resource="Top/Sports/Rugby"/>
  <narrow r:resource="Top/Sports/Inline_Skating"/>
  <narrow r:resource="Top/Sports/Snowmobiles"/>
  <narrow r:resource="Top/Sports/Soccer"/>
  <narrow r:resource="Top/Sports/Softball"/>
  <narrow r:resource="Top/Sports/Swimming"/>
  <narrow r:resource="Top/Sports/Table_Soccer"/>
  <narrow r:resource="Top/Sports/Table_Tennis"/>
  <narrow r:resource="Top/Sports/Tennis"/>
  <narrow r:resource="Top/Sports/Triathalon"/>
  <narrow r:resource="Top/Sports/Volleyball"/>
  <narrow r:resource="Top/Sports/Water_Skiing"/>
  <narrow r:resource="Top/Sports/Windsurfing"/>
  <narrow r:resource="Top/Sports/Horse_Racing"/>
  <narrow r:resource="Top/Sports/Wrestling"/>
  <narrow r:resource="Top/Sports/Unicycling"/>
  <narrow r:resource="Top/Sports/Running"/>
  <narrow r:resource="Top/Sports/Bocce"/>
  <narrow r:resource="Top/Sports/Kitesailing"/>
  <narrow r:resource="Top/Sports/Track_and_Field"/>
  <narrow r:resource="Top/Sports/Personal_Watercraft"/>
  <narrow r:resource="Top/Sports/Skateboarding"/>
  <narrow r:resource="Top/Sports/Sailing"/>
  <narrow r:resource="Top/Sports/Shooting"/>
  <narrow r:resource="Top/Sports/Wakeboarding"/>
  <narrow r:resource="Top/Sports/Highland_Games"/>
  <narrow r:resource="Top/Sports/Merchandise"/>
  <narrow r:resource="Top/Sports/Walking"/>
  <narrow r:resource="Top/Sports/Cheerleading"/>
  <narrow r:resource="Top/Sports/Gambling"/>
  <narrow r:resource="Top/Sports/Canoe_and_Kayaking"/>
  <narrow r:resource="Top/Sports/Skating"/>
  <narrow r:resource="Top/Sports/Surfing"/>
  <narrow r:resource="Top/Sports/Lacrosse"/>
  <narrow r:resource="Top/Sports/Fishing"/>
  <narrow r:resource="Top/Sports/Orienteering"/>
  <narrow r:resource="Top/Sports/Gymnastics"/>
  <narrow r:resource="Top/Sports/Croquet"/>
  <narrow r:resource="Top/Sports/Skibob"/>
  <narrow r:resource="Top/Sports/Ultimate_Frisbee"/>
  <narrow r:resource="Top/Sports/Frisbee"/>
  <narrow r:resource="Top/Sports/Fantasy"/>
  <narrow r:resource="Top/Sports/College_and_University"/>
  <narrow r:resource="Top/Sports/Flying_Discs"/>
  <narrow r:resource="Top/Sports/News"/>
  <narrow r:resource="Top/Sports/Curling"/>
  <narrow r:resource="Top/Sports/Training"/>
  <related r:resource="Top/Games/Gambling/Sports"/>
  <related r:resource="Top/Health/Fitness/Weightlifting/Bodybuilding"/>
  <symbolic r:resource="Hiking:Top/Recreation/Outdoors/Hiking"/>
  <symbolic r:resource="Paragliding:Top/Recreation/Aviation/Paragliding"/>
  <symbolic r:resource="Bodybuilding:Top/Health/Fitness/Weightlifting/Bodybuilding"/>
  <symbolic r:resource="Climbing:Top/Recreation/Climbing"/>
</Topic>

<Topic r:id="Top/Test">
  <tag catid="20"/>
  <d:Title>Test</d:Title>
  <narrow r:resource="Top/Test/Test"/>
  <narrow r:resource="Top/Test/Chez_Bob"/>
  <narrow r:resource="Top/Test/another"/>
  <narrow r:resource="Top/Test/Private"/>
  <narrow r:resource="Top/Test/Rules"/>
  <narrow r:resource="Top/Test/alphabet"/>
  <narrow r:resource="Top/Test/Stay_Out_really"/>
  <narrow r:resource="Top/Test/Eeeek_Oh_Yes"/>
  <narrow r:resource="Top/Test/This_Cat_Will_Not_Die"/>
  <related r:resource="Top/Test/Chez_Bob/Dinner_with_Andre"/>
  <symbolic r:resource="Blekko:Top/Test/Chez_Bob/Yikes"/>
  <symbolic r:resource="Eeeek Link:Top/Test/Eeeek_Oh_Yes"/>
  <symbolic r:resource="Wheee:Top/Society/Religion"/>
  <symbolic r:resource="pbmtest:Top/Games/Play_by_Mail"/>
  <symbolic r:resource="Hold:Top/Sports/Skiing/Nordic/Resorts"/>
  <newsGroup r:resource="news:alt.test"/>
  <newsGroup r:resource="news:comp.test"/>
</Topic>

<Topic r:id="Top/World">
  <tag catid="16"/>
  <d:Title>World</d:Title>
  <narrow r:resource="Top/World/Español"/>
  <narrow r:resource="Top/World/Chinese"/>
  <narrow r:resource="Top/World/Deutsch"/>
  <narrow r:resource="Top/World/Czech"/>
  <narrow r:resource="Top/World/Bulgarian"/>
  <narrow r:resource="Top/World/Français"/>
  <narrow r:resource="Top/World/Italiano"/>
  <narrow r:resource="Top/World/Nederlands"/>
  <narrow r:resource="Top/World/Lietuviu"/>
  <narrow r:resource="Top/World/Polska"/>
  <narrow r:resource="Top/World/Indonesia"/>
  <narrow r:resource="Top/World/Greek"/>
  <narrow r:resource="Top/World/Portuguese"/>
  <narrow r:resource="Top/World/Russian"/>
  <narrow r:resource="Top/World/Svenska"/>
  <narrow r:resource="Top/World/Esperanto"/>
  <narrow r:resource="Top/World/Norsk"/>
  <narrow r:resource="Top/World/Dansk"/>
  <narrow r:resource="Top/World/Urdu"/>
  <narrow r:resource="Top/World/Românã"/>
  <narrow r:resource="Top/World/Català"/>
  <narrow r:resource="Top/World/Gaelic"/>
  <narrow r:resource="Top/World/Korean"/>
  <narrow r:resource="Top/World/Simplified_Chinese"/>
  <narrow r:resource="Top/World/Afrikaans"/>
  <narrow r:resource="Top/World/Turkish"/>
  <narrow r:resource="Top/World/Faroese"/>
  <narrow r:resource="Top/World/Bosnian"/>
  <narrow r:resource="Top/World/Malaysian"/>
  <narrow r:resource="Top/World/Vlaams"/>
  <narrow r:resource="Top/World/Thai"/>
  <narrow r:resource="Top/World/Letzebuergesch"/>
  <narrow r:resource="Top/World/Finland"/>
  <narrow r:resource="Top/World/Farsi"/>
</Topic>

<Topic r:id="Top/Private">
  <tag catid="19"/>
  <d:Title>Private</d:Title>
  <narrow r:resource="Top/Private/Cybion"/>
</Topic>

<Topic r:id="Top/Bookmarks">
  <tag catid="18"/>
  <d:Title>Bookmarks</d:Title>
  <narrow r:resource="Top/Bookmarks/A"/>
  <narrow r:resource="Top/Bookmarks/B"/>
  <narrow r:resource="Top/Bookmarks/C"/>
  <narrow r:resource="Top/Bookmarks/D"/>
  <narrow r:resource="Top/Bookmarks/E"/>
  <narrow r:resource="Top/Bookmarks/F"/>
  <narrow r:resource="Top/Bookmarks/G"/>
  <narrow r:resource="Top/Bookmarks/H"/>
  <narrow r:resource="Top/Bookmarks/I"/>
  <narrow r:resource="Top/Bookmarks/J"/>
  <narrow r:resource="Top/Bookmarks/K"/>
  <narrow r:resource="Top/Bookmarks/L"/>
  <narrow r:resource="Top/Bookmarks/M"/>
  <narrow r:resource="Top/Bookmarks/N"/>
  <narrow r:resource="Top/Bookmarks/O"/>
  <narrow r:resource="Top/Bookmarks/P"/>
  <narrow r:resource="Top/Bookmarks/Q"/>
  <narrow r:resource="Top/Bookmarks/R"/>
  <narrow r:resource="Top/Bookmarks/S"/>
  <narrow r:resource="Top/Bookmarks/T"/>
  <narrow r:resource="Top/Bookmarks/U"/>
  <narrow r:resource="Top/Bookmarks/V"/>
  <narrow r:resource="Top/Bookmarks/W"/>
  <narrow r:resource="Top/Bookmarks/X"/>
  <narrow r:resource="Top/Bookmarks/Y"/>
  <narrow r:resource="Top/Bookmarks/Z"/>
</Topic>

</RDF>

Der Inhalt wird in der XML-Datei "content.xml" abgebildet. Abgesehen vom Kopf ("<RDF ...>") werden in der Datei die beiden Elemente "<Topic>" und "<ExternalPage>" definiert. "<Topic>" bildet die Verbindung zur Datei "structure.xml".

<!-- Name     content.xml -->
<?xml version="1.0" encoding="utf-8" ?> 
<RDF xmlns:r="http://www.w3.org/TR/RDF/"
     xmlns:d="http://purl.org/dc/elements/1.0/"
     xmlns  ="http://directory.mozilla.org/rdf">

<Topic r:id="Top">
  <tag catid="1"/>
  <d:Title>Top</d:Title>
</Topic>

<!-- Jedes Element "Topic" beginnt mit der Nennung des vollständigen Pfades, der Position im Baum also. -->
<Topic r:id="Top/Arts">
  <!-- Katalog-ID, die später zur Zuordnung herangezogen wird -->
  <tag catid="2"/>
  <!-- Titel des Topics -->
  <d:Title>Arts</d:Title>
  <!-- Falls in dem Topic Links sind, werden diese nachfolgend aufgelistet. -->
  <link r:resource="http://www3.bc.sympatico.ca/PHILLIPSHOTGLASS/GlassPage.html"/>
<!-- Schliessen des Elements -->
</Topic>

<!-- Wenn Links mit dem Tag "<link r:resource=...>" definiert wurden, so folgt dem Element "<Topic>" unmittelbar das Element "<ExternalPage>" mit einer genauen Beschreibung. Zuerst wird mit dem Attribut "about" die Verbindung zum Element "<link ...>" hergestellt.-->
<ExternalPage about="http://www3.bc.sympatico.ca/PHILLIPSHOTGLASS/GlassPage.html">
  <!-- Titel des Links -->
  <d:Title>John phillips Blown glass</d:Title>
  <!-- Beschreibung des Links -->
  <d:Description>A small display of glass by John Phillips</d:Description>
<!-- Schliessen des Elements -->
</ExternalPage>

<Topic r:id="Top/Business">
  <tag catid="3"/>
  <d:Title>Business</d:Title>
</Topic>

<Topic r:id="Top/Computers">
  <tag catid="4"/>
  <d:Title>Computers</d:Title>
  <link r:resource="http://www.cs.tcd.ie/FME/"/>
  <link r:resource="http://pages.whowhere.com/computers/pnyhlen/Timeline.html"/>
</Topic>

<ExternalPage about="http://www.cs.tcd.ie/FME/">
  <d:Title>FME HUB</d:Title>
  <d:Description>Formal Methods Europe (FME) is a European organization supported by the Commission of the European Union (via ESSI of the ESPRIT programme),
 with the mission of         promoting and supporting the industrial use of formal methods for computer systems development.</d:Description>
</ExternalPage>

<ExternalPage about="http://pages.whowhere.com/computers/pnyhlen/Timeline.html">
  <d:Title>Computer Timeline</d:Title>
  <d:Description>A brief description of the eras in computing.</d:Description>
</ExternalPage>

<Topic r:id="Top/Games">
  <tag catid="5"/>
  <d:Title>Games</d:Title>
</Topic>

<Topic r:id="Top/Health">
  <tag catid="6"/>
  <d:Title>Health</d:Title>
</Topic>

<Topic r:id="Top/Home">
  <tag catid="7"/>
  <d:Title>Home</d:Title>
  <link r:resource="http://www.homeideas.com/"/>
  <link r:resource="http://www.housenet.com/"/>
  <link r:resource="http://members.aol.com/yodapro/index.html"/>
  <link r:resource="http://www.marthastewart.com"/>
  <link r:resource="http://www.mfgsupply.com"/>
  <link r:resource="http://www.bccondo.com"/>
  <link r:resource="http://www.contractornet.com"/>
  <link r:resource="http://www.kcweb.com/fl/freelance.htm"/>
  <link r:resource="http://thefamilyrealtor.com"/>
  <link r:resource="http://members.xoom.com/tipztime"/>
  <link r:resource="http://www.cococo.net/~tj/house/"/>
  <link r:resource="http://www.suite101.com/articles/article.cfm/7628"/>
  <link r:resource="http://www.virtual.net.au/~belair"/>
</Topic>

<ExternalPage about="http://www.homeideas.com/">
  <d:Title>Home Ideas: Home Improvement Ideas for Kitchen, Bath, Yard and Garden, etc.</d:Title>
  <d:Description>The ultimate resource for home projects. Research projects using past issues of Today's Homeowner magazine, request free product literature, and link to over 700 industry websites.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.housenet.com/">
  <d:Title>HouseNet.Com</d:Title>
  <d:Description>Home improvement, Gardening, Decorating, Sewing, and Money Saving Information.</d:Description>
</ExternalPage>

<ExternalPage about="http://members.aol.com/yodapro/index.html">
  <d:Title>Pro Flooring</d:Title>
  <d:Description>We sell and install all types of floor coverings. Pergo, Ceramic Tile, Carpet and Vinyl. We offer free estimates and Shop @ Home services.
</d:Description>
</ExternalPage>

<ExternalPage about="http://www.marthastewart.com">
  <d:Title>Martha Stewart Living</d:Title>
</ExternalPage>

<ExternalPage about="http://www.mfgsupply.com">
  <d:Title>Manufacturer's Supply</d:Title>
  <d:Description>Your one-stop source for lawnmower, chainsaw, and small engine parts. We offer online ordering of all our parts and great service too.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.bccondo.com">
  <d:Title>BCCondo.com</d:Title>
  <d:Description>Seeks to provide both prospective and current   condo owners with useful information on   condominium living in the province.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.contractornet.com">
  <d:Title>ContractorNet</d:Title>
  <d:Description>Search our database before you hire a residential or commercial contractor!   Each contractor listed has a current certificate of   insurance and copies of applicable licenses on file with our office. Other accessible info includes; years  in business, number of employees, professional affliations, and more. Site features include; state licensing statutes and government phone numbers, articles, archive of consumer  Q&amp;A's, message board. If you're in the market for a contractor, this is a must-see site!</d:Description>
</ExternalPage>

<ExternalPage about="http://www.kcweb.com/fl/freelance.htm">
  <d:Title>Freelance! Free stuff for your home!</d:Title>
  <d:Description>Very large selection of free samples and products. Updated daily!  Free samples, cd-roms, desktop themes, books, contests and more!</d:Description>
</ExternalPage>

<ExternalPage about="http://thefamilyrealtor.com">
  <d:Title>TheFamilyRealtor.com</d:Title>
</ExternalPage>

<ExternalPage about="http://members.xoom.com/tipztime">
  <d:Title>Tipz Time</d:Title>
  <d:Description>Home on the web with tips and ideas for household including indoors and outdoors, chat, seasonal, and more!</d:Description>
</ExternalPage>

<ExternalPage about="http://www.cococo.net/~tj/house/">
  <d:Title>Custom House Plans for .25 cents per square foot.</d:Title>
  <d:Description>Why pay a fortune to have your new home designed.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.suite101.com/articles/article.cfm/7628">
  <d:Title>Homeschooling Catholic</d:Title>
  <d:Description>Why one family homeschools, a list of Catholic curriculums on the internet, a list of families with homeschooling web pages and FREEBIES for homeschooling families.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.virtual.net.au/~belair">
  <d:Title>Belair Property Maintenance Services</d:Title>
  <d:Description>Belair Property Maintenance specialises in lawn mowing, garden and turf maintenance in Melbournes outer eastern Suburbs.Our service also incorporates Integrated Pest Control in turf ,garden and horticultural situations using either biological and chemical applications.</d:Description>
</ExternalPage>

<Topic r:id="Top/News">
  <tag catid="8"/>
  <d:Title>News</d:Title>
  <link r:resource="http://www.bcity.com/bollettino"/>
  <link r:resource="http://news.bbc.co.uk"/>
  <link r:resource="http://dailynews.yahoo.com/headlines/top_stories/"/>
  <link r:resource="http://www.pressdigest.org/"/>
  <link r:resource="http://www.cnn.com/"/>
  <link r:resource="http://tvnews.vanderbilt.edu/"/>
  <link r:resource="http://internetv.virtualspace.net"/>
  <link r:resource="http://attention.hypermart.net"/>
  <link r:resource="http://www.palmetto.org/noprint.htm"/>
  <link r:resource="http://kresch.com/resources/Content/News_Tickers/newstickers.html"/>
  <link r:resource="http://www.msnbc.com"/>
  <link r:resource="http://burn.ucsd.edu/~mai/news.html"/>
  <link r:resource="http://www.abilityinfo.com/ticker.html"/>
  <link r:resource="http://www.obscurestore.com"/>
  <link r:resource="http://www.pathfinder.com/welcome/"/>
</Topic>

<ExternalPage about="http://www.bcity.com/bollettino">
  <d:Title>International Bulletin</d:Title>
  <d:Description>International politics.  Italian, French and (some) English</d:Description>
</ExternalPage>

<ExternalPage about="http://news.bbc.co.uk">
  <d:Title>BBC News</d:Title>
  <d:Description>International news from the British Broadcasting Corporation</d:Description>
  <priority>1</priority>
</ExternalPage>

<ExternalPage about="http://dailynews.yahoo.com/headlines/top_stories/">
  <d:Title>Reuters News Online</d:Title>
  <d:Description>This is Yahoo with Reuters news coverage and links to AP and other coverage. Reuters is a worldwide service that enjoys a solid reputation.</d:Description>
  <priority>1</priority>
</ExternalPage>

<ExternalPage about="http://www.pressdigest.org/">
  <d:Title>Pressdigest</d:Title>
  <d:Description>International and multilingual press digest.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.cnn.com/">
  <d:Title>CNN</d:Title>
  <d:Description>CNN's comprehensive web site with links to many valuable services including very prompt sports, financial and breaking news reports. You may be able to wait until tomorrow for all the details but CNN can give you clear and fast news when you want it NOW.</d:Description>
</ExternalPage>

<ExternalPage about="http://tvnews.vanderbilt.edu/">
  <d:Title>Vanderbilt Television News Archive</d:Title>
  <d:Description>Collection of network news   broadcasts -- ABC, CBS, NBC, CNN, PBS --  from 1968 to the present. Copies of videotape  available on loan basis. Fee charged.</d:Description>
</ExternalPage>

<ExternalPage about="http://internetv.virtualspace.net">
  <d:Title>Internet Television</d:Title>
  <d:Description>International news in real audio and video.</d:Description>
</ExternalPage>

<ExternalPage about="http://attention.hypermart.net">
  <d:Title>@ttention News</d:Title>
  <d:Description>news about politics, business, and technology</d:Description>
</ExternalPage>

<ExternalPage about="http://www.palmetto.org/noprint.htm">
  <d:Title>Opinions newspaper editors rejected</d:Title>
  <d:Description>Publishes letters and opinion-editorial items submitted to but rejected by newspapers, frequently with good reason. Read what the newspapers thought you could do without.</d:Description>
</ExternalPage>

<ExternalPage about="http://kresch.com/resources/Content/News_Tickers/newstickers.html">
  <d:Title>All News Tickers on One Page</d:Title>
  <d:Description>Seven different news ticker styles, news headlines for your web site, free for the download.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.msnbc.com">
  <d:Title>MS NBC</d:Title>
  <d:Description>Provides up-to-date news and weather information from around the country. Other features include NBC news shows such as Dateline and the Today Show that you may prefer seeing on your television set. Also includes business news from CNBC and the Wall Street Journal.</d:Description>
</ExternalPage>

<ExternalPage about="http://burn.ucsd.edu/~mai/news.html">
  <d:Title>MA Infoshop News Kiosk</d:Title>
  <d:Description>A frequently updated roundup of news and breaking events of interest to activists and police agencies. Lots on anarchy, some on radical feminism and other subjects.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.abilityinfo.com/ticker.html">
  <d:Title>International Disability News Ticker</d:Title>
  <d:Description>This constantly updated site tracks news stories from web based news sources pertaining to the area of disability.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.obscurestore.com">
  <d:Title>Obscure Store and Reading Room</d:Title>
  <d:Description>A daily collection of mostly off-beat news articles, essays and columns. This is an interesting collection of features that can relieve News Tedium!</d:Description>
</ExternalPage>

<ExternalPage about="http://www.pathfinder.com/welcome/">
  <d:Title>Time Warner's Pathfinder!</d:Title>
  <d:Description>A gateway to news magazines and some online services.</d:Description>
</ExternalPage>

<Topic r:id="Top/Recreation">
  <tag catid="9"/>
  <d:Title>Recreation</d:Title>
  <link r:resource="http://www.curiouscat.com/clubs/"/>
</Topic>

<ExternalPage about="http://www.curiouscat.com/clubs/">
  <d:Title>Curious Cat Club Connections</d:Title>
  <d:Description>Find local activities and contacts for local recreation  organizations worldwide such as dances, hiking clubs, book discussion groups, learning opportunities, charity work, ultimate clubs, singles clubs...</d:Description>
</ExternalPage>

<Topic r:id="Top/Reference">
  <tag catid="10"/>
  <d:Title>Reference</d:Title>
  <link r:resource="http://www.bookmagazine.com/"/>
  <link r:resource="http://www.sosig.ac.uk/"/>
  <link r:resource="http://www.mtnds.com/af/"/>
  <link r:resource="http://www.infoplease.com"/>
  <link r:resource="http://www-sci.lib.uci.edu/HSG/Ref.html"/>
  <link r:resource="http://thorplus.lib.purdue.edu/reference/index.html"/>
  <link r:resource="http://www.uky.edu/ArtsSciences/Classics/lexindex.html"/>
  <link r:resource="http://www.dumblaws.com/"/>
  <link r:resource="http://www.abp1.com/1getsmrt/index.html"/>
  <link r:resource="http://www.cybergeography.org/atlas/atlas.html"/>
  <link r:resource="http://www.sau.edu/CWIS/Internet/Wild/index.htm"/>
</Topic>

<ExternalPage about="http://www.bookmagazine.com/">
  <d:Title>Book - The Magazine for the Reading Life</d:Title>
</ExternalPage>

<ExternalPage about="http://www.sosig.ac.uk/">
  <d:Title>Social Science Information Gateway - SOSIG</d:Title>
</ExternalPage>

<ExternalPage about="http://www.mtnds.com/af/">
  <d:Title>Acronym finder</d:Title>
</ExternalPage>

<ExternalPage about="http://www.infoplease.com">
  <d:Title>Information Please</d:Title>
  <d:Description>Combines an encyclopedia, a dictionary, and several up-to-the minute almanacs.</d:Description>
  <priority>1</priority>
</ExternalPage>

<ExternalPage about="http://www-sci.lib.uci.edu/HSG/Ref.html">
  <d:Title>Martindale's The Reference Desk</d:Title>
</ExternalPage>

<ExternalPage about="http://thorplus.lib.purdue.edu/reference/index.html">
  <d:Title>THOR+: The Virtual Reference Desk</d:Title>
</ExternalPage>

<ExternalPage about="http://www.uky.edu/ArtsSciences/Classics/lexindex.html">
  <d:Title>What Do You Want to Know Today?</d:Title>
  <d:Description>Ancient and classic culture, literature and languages search and retrieval tool.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.dumblaws.com/">
  <d:Title>Dumb Laws</d:Title>
  <d:Description>a huge collection of the most senseless laws in the entire United States.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.abp1.com/1getsmrt/index.html">
  <d:Title>The Virtual Encyclopedia - brought to you by ABP</d:Title>
</ExternalPage>

<ExternalPage about="http://www.cybergeography.org/atlas/atlas.html">
  <d:Title>An Atlas of Cyberspaces</d:Title>
  <d:Description>An atlas of maps and graphic representations of the geographies of the new electronic territories of the Internet, WWW and other emerging Cyberspaces.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.sau.edu/CWIS/Internet/Wild/index.htm">
  <d:Title>Best Information on the Net</d:Title>
  <d:Description>A guide to high-quality information resources on the net, appropriate for college students, faculty and administration, chosen by a librarian/information specialist.</d:Description>
</ExternalPage>

<Topic r:id="Top/Regional">
  <tag catid="11"/>
  <d:Title>Regional</d:Title>
  <link r:resource="http://www.soon.org.uk/country/language.htm"/>
</Topic>

<ExternalPage about="http://www.soon.org.uk/country/language.htm">
  <d:Title>Your own language and country</d:Title>
  <d:Description>A growing set of pages for different countries.  Links for tourism, information, dictionaries,  learning English, search engines, life &amp; religion, &amp; more.</d:Description>
</ExternalPage>

<Topic r:id="Top/Science">
  <tag catid="12"/>
  <d:Title>Science</d:Title>
  <link r:resource="http://www.ibm.com/patents"/>
  <link r:resource="http://www.sciencekomm.at"/>
  <link r:resource="http://www.aaas.org/"/>
  <link r:resource="http://www.techexpo.com/"/>
  <link r:resource="http://www.csiro.au/"/>
  <link r:resource="http://www.larc.nasa.gov/"/>
  <link r:resource="http://www.carl.org/carlweb/"/>
  <link r:resource="http://www.w3.org/hypertext/DataSources/bySubject/Overview.html"/>
  <link r:resource="http://www.siec.k12.in.us/~west/sites/scigen.htm"/>
  <link r:resource="http://www.ukoln.ac.uk/services/elib/"/>
  <link r:resource="http://www.webcom.com/webscout/links/science/science.html"/>
</Topic>

<ExternalPage about="http://www.ibm.com/patents">
  <d:Title>IBM Patent Server</d:Title>
</ExternalPage>

<ExternalPage about="http://www.sciencekomm.at">
  <d:Title>science.komm</d:Title>
  <d:Description>Bioscience and medical journal links, advice and links concerning research communication (writing, presenting etc.)</d:Description>
</ExternalPage>

<ExternalPage about="http://www.aaas.org/">
  <d:Title>American Association for the Advancement of Science</d:Title>
  <d:Description>Research news, issue papers. Educational programs, science policy (U.S. and international).</d:Description>
</ExternalPage>

<ExternalPage about="http://www.techexpo.com/">
  <d:Title>Tech Expo</d:Title>
  <d:Description>Exposition of high technology companies and products on the WWW</d:Description>
</ExternalPage>

<ExternalPage about="http://www.csiro.au/">
  <d:Title>CSIRO Australia</d:Title>
  <d:Description>The Commonwealth Scientific and Industrial Research Organisation (CSIRO) is Australia's largest scientific research agency. Areas of research and development include agriculture, forestry, agribusiness, energy, manufacturing, environment, marine resources, climate and atmosphere, mining, petroleum, radio astronomy, pharmaceuticals, and information technology.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.larc.nasa.gov/">
  <d:Title>NASA Langley Research Center</d:Title>
  <d:Description>In Hampton, VA. Established in 1917 as the first national civil aeronautics laboratory, NASA Langley has become a world-class center for aeronautics, earth science, space technology and structures and materials research.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.carl.org/carlweb/">
  <d:Title>CarlWeb</d:Title>
  <d:Description>search databases for bibliography</d:Description>
</ExternalPage>

<ExternalPage about="http://www.w3.org/hypertext/DataSources/bySubject/Overview.html">
  <d:Title>WWW Virtual Library</d:Title>
  <d:Description>an expert-run catalog of the web</d:Description>
</ExternalPage>

<ExternalPage about="http://www.siec.k12.in.us/~west/sites/scigen.htm">
  <d:Title>General Science Sites</d:Title>
  <d:Description>an annotated list</d:Description>
</ExternalPage>

<ExternalPage about="http://www.ukoln.ac.uk/services/elib/">
  <d:Title>eLib: Electronic Libraries Programme</d:Title>
  <d:Description>the eLib programme consists of around 60 projects</d:Description>
</ExternalPage>

<ExternalPage about="http://www.webcom.com/webscout/links/science/science.html">
  <d:Title>WebScout</d:Title>
  <d:Description>A searchable index of the Web sites, discussion groups and archives.</d:Description>
</ExternalPage>

<Topic r:id="Top/Shopping">
  <tag catid="13"/>
  <d:Title>Shopping</d:Title>
  <link r:resource="http://www.esmarts.com/"/>
  <link r:resource="http://www.bdscodak.com"/>
  <link r:resource="http://www.choicemall.com/"/>
</Topic>

<ExternalPage about="http://www.esmarts.com/">
  <d:Title>eSmarts</d:Title>
  <d:Description>eSmarts helps consumers find the lowest possible prices on the web. They compare prices at different Internet stores, list coupons (including many $10 off coupons), discuss sales and share great shopping tips.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.bdscodak.com">
  <d:Title>BD Scodak - personalized children's books for your child's education</d:Title>
  <d:Description>BD Scodak is your source for personalized children's books customized with your child's information right next to popular cartoon, religious, sports, and tv characters and themes.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.choicemall.com/">
  <d:Title>Choice World</d:Title>
  <d:Description>Choice Mall - The #1 global marketplace on the Internet.  Thousands of stores offer quality, unique products and services, art and entertainment, books and music, gifts, food, real estate, health, sports, and fitness -- all under one roof!</d:Description>
</ExternalPage>

<Topic r:id="Top/Society">
  <tag catid="14"/>
  <d:Title>Society</d:Title>
  <link r:resource="http://www.yforum.com/"/>
</Topic>

<ExternalPage about="http://www.yforum.com/">
  <d:Title>Y? The National Forum on People's Differences</d:Title>
  <d:Description>The nation's only forum allowing people to ask and receive answers to the uncomfortable and even embarrassing questions they've always wanted to ask people who are different from themselves. All questions and answers are acceptable, as long as they promote dialogue and are not asked or answered out of hate.</d:Description>
  <priority>1</priority>
</ExternalPage>

<Topic r:id="Top/Sports">
  <tag catid="15"/>
  <d:Title>Sports</d:Title>
  <link r:resource="http://www.isportsnet.com"/>
  <link r:resource="http://www.infoplease.com/sports.html"/>
  <link r:resource="http://thor.prohosting.com/~sportiq/"/>
  <link r:resource="http://www.sportsearch.com"/>
</Topic>

<ExternalPage about="http://www.isportsnet.com">
  <d:Title>Internet Sports Awards</d:Title>
  <d:Description>This site allows Internet users the opportunity to vote for the best players, teams and websites in the following sports: baseball, basketball, golf, football, hockey, auto racing,tennis, soccer, pro wrestling, sports media, sports products and boxing. Over 600 awards will be announced on December 1st. 2 million plus to vote in the inaugural year of the awards.</d:Description>
</ExternalPage>

<ExternalPage about="http://www.infoplease.com/sports.html">
  <d:Title>Information Please</d:Title>
  <d:Description>Information Please Sports Almanac Facts, figures, scores. Find the facts about sports here.</d:Description>
</ExternalPage>

<ExternalPage about="http://thor.prohosting.com/~sportiq/">
  <d:Title>Sports IQ Center</d:Title>
  <d:Description>Find your sports IQ pick a sporting event champion get a sports penpal chat about sports and much more!!</d:Description>
</ExternalPage>

<ExternalPage about="http://www.sportsearch.com">
  <d:Title>SportSearch.com -- Just Sports, Baby.</d:Title>
  <d:Description>NewHoo! style sports search engine.</d:Description>
</ExternalPage>

<Topic r:id="Top/Test">
  <tag catid="20"/>
  <d:Title>Test</d:Title>
  <link r:resource="http://skip.incog.com/"/>
  <link r:resource="http://home.digitalcity.com/washington/"/>
</Topic>

<ExternalPage about="http://skip.incog.com/">
  <d:Title>SKIP IP-level Encryption</d:Title>
</ExternalPage>

<ExternalPage about="http://home.digitalcity.com/washington/">
  <d:Title>Digital City - Washington, DC</d:Title>
  <priority>1</priority>
</ExternalPage>

<Topic r:id="Top/World">
  <tag catid="16"/>
  <d:Title>World</d:Title>
  <link r:resource="http://directory.mozilla.org/World/world.html"/>
</Topic>

<ExternalPage about="http://directory.mozilla.org/World/world.html">
  <d:Title>About the World Categories</d:Title>
  <d:Description>Information about this section of the Open Directory, and how to submit a new language category for inclusion here.</d:Description>
</ExternalPage>

<Topic r:id="Top/Private">
  <tag catid="19"/>
  <d:Title>Private</d:Title>
</Topic>

<Topic r:id="Top/Bookmarks">
  <tag catid="18"/>
  <d:Title>Bookmarks</d:Title>
</Topic>

</RDF>

Parser

Nachfolgend wird der Parser gezeigt, der als Klasse "import_dmoz" definiert wurde.

<?php
## Name     open_xmlproject.inc.php

## Datenquelle ##
define('STRUCTURE', "data/structure.xml");
define('CONTENT',   "data/content.xml");

## Datenbankzugriff ##
$strDB   = "php5test";
$strUser = "root";
$strPass = "";
$strServ = "localhost";

## Handle erzeugen und Datenbank auswählen
$hdlDB = mysql_pconnect($strServ, $strUser, $strPass) or die("Datenbankfehler: " . mysql_error() . "</body></html>");
mysql_select_db($strDB, $hdlDB);

## Funktion zum einfachen Ausführen von SQL
function my_query($strQuery, $blnDebug = FALSE) {
  global $hdlDB;
  if ($blnDebug == TRUE)
  {
    printf("<p>Abfrage:<br />%s<p>", $strQuery);
  }
  $hdlRS = FALSE;
  $hdlRS = @mysql_query($strQuery, $hdlDB) or die("Fehler bei der Ausführung: <i>" . mysql_error($hdlDB) . "</i> in:<br />" . $strQuery . "</body></html>"
);
  ## Rückgabe des Datensatzhandles, wenn vorhanden
  return $hdlRS;
}

## Erzeugen der Tabelle, löschen der alten
function create_table_topics() {
  $strSQL = "DROP TABLE IF EXISTS topic";
  my_query($strSQL);
  $strSQL = <<<SQL
  CREATE TABLE topic (
    id int(11)                NOT NULL auto_increment,
    topic_id     int(11)      NOT NULL,
    topic_parent int(11)      NOT NULL,
    topic_title  varchar(255) NOT NULL,
    topic_level  tinyint(4)   NOT NULL,
    topic_desc   text,
    PRIMARY KEY (id),
    KEY topic_id (topic_id),
    KEY topic_parent (topic_parent),
    KEY topic_title (topic_title)
  )
SQL;
  my_query($strSQL);
}

function create_table_content() {
  $strSQL = "DROP TABLE IF EXISTS content";
  my_query($strSQL);
  $strSQL = <<<SQL
  CREATE TABLE content (
    id            int(11)      NOT NULL auto_increment,
    topic_id      int(11)      NOT NULL,
    content_page  varchar(255) NOT NULL,
    content_title varchar(255) NULL,
    content_desc  text         NULL,
    PRIMARY KEY (id),
    KEY topic_id (topic_id)
  )
SQL;
  my_query($strSQL);
}

##### Klassen zum Import der XML-Daten #####

class import_dmoz
{
  ## Definition der Eigenschaften
  ## Handle zum XML-Parser und die geöffneten Datendateien
  var $hdlParser;
  var $hdlDataStructure;
  var $hdlDataContent;
  ## Die Namen der XML-Datendateien (einschliesslich Pfad)
  var $strStructure;
  var $strContent;
  ## Da die Struktur der Daten in der Datenbank nicht derjenigen der XML-Dateien
  ## entspricht, müssen einige Werte zwischengespeichert werden.
  var $strTopic;           ## Topic
  var $strTitle;           ## Name des Topic oder Links
  var $strDescription;     ## Beschreibender Text Topic oder Link
  var $intCatid;           ## Katalog-ID
  var $strPage;            ## Link zur Seite (Content)
  var $strNarrow;          ## Verweis auf die Content-Datei
  ## Steuerung der Funktionen des XML-Parsers
  var $strNextElement;     ## Nächstes einzulesendes Element
  var $blnUpdate;          ## Update in der zweiten Phase
    
  ## Die erste Methode ist der Konstruktor. Sie wird aufgerufen, wenn eine
  ## Instanz der Klasse angelegt wird. Standardmässig kann ein Parser nicht
  ## innerhalb einer Klasse erreicht werden.
  function import_dmoz()
  {
    ## Erzeugen eines Handles auf einen neuen XML-Parser
    $this->hdlParser = xml_parser_create("UTF-8");
    ## Dieser Parser wird innerhalb des Objekts sichtbar gemacht
    xml_set_object($this->hdlParser, $this);
  }

  ## Funktion liest die Daten innerhalb der <TOPIC>- und <NARROW>-Struktur.
  ## Der Aufruf erfolgt in jedem Element, das Attribute enthält. 
  function charData($hdlParser, $strData)
  {
    if (strlen(trim($strData)) > 0)
    {
      ## Die Eigenschaft "strNextElement" entscheidet, wohin die Daten
      ## gespeichert werden. Mit Hilfe der "switch"-Anweisung werden die
      ## Daten der richtigen Eigenschaft zugewiesen.    
      switch($this->strNextElement)
      {
        case "CATID":
          $this->intCatid        = (int) $strData;
          break;
        case "D:DESCRIPTION":
          ## Umwandlung der UTF-8-Kodierung, ohne welche die Umlaute 
          ## nicht richtig dargestellt würden.
          $this->strDescription .= (string) addslashes(utf8_decode($strData));
          break;
        case "D:TITLE":
          $this->strTitle        = (string) addslashes(utf8_decode($strData));
          break;
      }
    }
  }
  
  ## Die folgende Methode wird mit jedem öffnenden Tag der XML-Datei aufgerufen.
  ## Attribute werden als Array übergeben, da mehrere Attribute zulässig sind.
  ## Dieses Array ist assiziiert und als Schlüsselname der der Attributname 
  ## eingesetzt.
  function startElement($hdlParser, $strName, $arrAttribute)
  {
    switch($strName)
    {
      ## Beginnt ein neuer Topic, so wird der Name dem Attribut "r:id"
      ## entnommen und in der Eigenschaft "strTopic" gespeichert.
      case "TOPIC":      ## Beginn eines neuen Topic
        $this->strTopic = addslashes(utf8_decode($arrAttribute["R:ID"]));
        break;
      ## Innerhalb des Topics werden die untergeordneten Elemente defginiert.
      ## Die Zuordnung kann erst erfolgen, wenn zuvor alle Topics erfasst wurden.
      ## Dieser Teil wird erst im zweiten Durchlauf der Datei verwendet
      ## (blnUpdate = TRUE).
      case "NARROW":
        if ($this->blnUpdate == TRUE)
        {
          $this->strNarrow = addslashes(utf8_decode($arrAttribute["R:RESOURCE"]));
          ## Ermittlung der Ebene innerhalb der Struktur durch Zählen der "/"-Zeichen.
          $arrNarrow       = explode("/", $this->strNarrow);
          $intLevel        = count($arrNarrow) - 1;
          $strTopic        = $arrNarrow[$intLevel];
          ## Jetzt sind alle Daten vorhanden und die Zuordnung wird aktualisiert.
          $strSQL          = "UPDATE topic SET topic_parent = $this->intCatid WHERE";
          $strSQL         .= " topic_title = \"$strTopic\" AND topic_level = $intLevel";
          my_query ($strSQL, FALSE);
        }
        break;
      ## Falls es sich um Inhalt (aus der Datei "content.xml") handelt, so kann das
      ## Element "<ExternalPage>" auftreten. Hier ist das Attribut "about" interessant.
      case "EXTERNALPAGE":
        $this->strPage = addslashes($arrAttribute["ABOUT"]);
        break;
      case "TAG":
          $this->intCatid = (int) $arrAttribute['CATID'];
          break;
      ## In allen anderen Fällen wird der Name des Elements gespeichert, damit die
      ## Funktion "charData" auf den Inhalt zugreifen kann.
      default:
        $this->strNextElement = $strName;
    }
  }
  
  ## Die Funktion "endElement" wird aufgerufen, wenn ein Element geschlossen wird.
  function endElement($hdlParser, $strName)
  {
    switch($strName)
    {
      ## Das Ende der "<Topic>"-Struktur wird erkannt und in die Datenbank
      ## geschrieben. Topic ist nur im ersten Durchlauf interessant, kommt aber auch
      ## in der zweiten Datei vor, dazu die "if"-Anweisung am Anfang.
      case "TOPIC":
        if ($this->blnUpdate == FALSE)
        {  
          ## Ermittlung der Ebene innerhalb der Struktur durch Zählen der "/"-Zeichen.
          $intLevel = count(explode("/", $this->strTopic)) - 1;
          ## Mit den inzwischen von den anderen Funktionen ermittelten Daten kann
          ## nun die "INSERT"-Anweisung aufgebaut werden.
          $strSQL  = "INSERT INTO topic (topic_id, topic_parent, topic_title, topic_level, topic_desc) ";
          $strSQL .= "VALUES ($this->intCatid, 0, \"$this->strTitle\", $intLevel, \"$this->strDescription\")";
          my_query($strSQL, FALSE);
          ## Dass die Beschreibung HTML-Tags enthalten kann führt möglicherweise zu
          ## Problemen mit dem Parser. Die Funktion "charData" wird mehrfach 
          ## aufgerufen. Damit dennoch die vollständige Beschreibung erfasst wird, 
          ## sammelt die Eigenschaft "strDescription" diese. Am Ende muss dieser Wert
          ## gezielt gelöscht werden.
          unset($this->strDescription);
        }
        break;
      ## Beim Erfassen des Inhalts löst das Ende des Elements "<ExternalPage>" die
      ## "INSERT"-Anweisung aus, mit der in die Datenbank geschrieben wird.
      case "EXTERNALPAGE":
        $strSQL  = "INSERT INTO content (topic_id, content_page, content_title, content_desc) ";
        $strSQL .= "VALUES ($this->intCatid, \"$this->strPage\", \"$this->strTitle\", \"$this->strDescription\")";
        my_query($strSQL, FALSE);
        unset($this->strDescription);
        break;
    }
  }

  ## Die Funktion "avoid_error" sucht nach einem XML-Fehler das Ende des fehlerhaften
  ## Elements und setzt erst dann fort, um Wiedereintrittsfehler zu vermeiden.
  function avoid_error($hdlFile)
  {
    $dummy = fgets($hdlFile, 4096);
    if (   (strpos($dummy, "/Topic>")        == 1)
        or (strpos($dummy, "/ExternalPage>") == 1))
    {
      return FALSE;
    }
    else
    {
      return TRUE;
    }
  }
  
  ## Die Funktion "parse_xml_topics" liest die Datei "structure.xml" und
  ## übernimmt die Daten in die Datenbank.
  function parse_xml_topics()
  {
    ## Definition der Handler-Funktionen
    xml_set_element_handler($this->hdlParser, "startElement", "endElement");
    xml_set_character_data_handler($this->hdlParser, "charData");
    $strStructure = STRUCTURE;
    $this->hdlDataStructure = fopen($strStructure, "r");
    ## Einlesen aller Topics
    $this->blnUpdate = FALSE;
    echo "<p>Beginne Import der Daten...</p>";
    ## Aufruf des eigentlichen XML-Parsers in einer "while"-Schleife, welche
    ## die Datei zeilenweise durchläuft. Der Aufruf erfolgt in einer "if"-
    ## Anweisung.
    while($strXMLData = fgets($this->hdlDataStructure, 4096)) 
    {
      ## Die Funktion "xml_parse" gibt "FALSE" zurück, wenn ein Fehler auftrat.
      ## Fehler führen nicht zum Abbruch, sondern zur Anzeige des Fehleres mit 
      ## Hilfe der entsprechenden XML-Funktionen.
      if (!xml_parse($this->hdlParser, $strXMLData, feof($this->hdlDataStructure)))
      {
        printf("<br>XML Fehler: %s in Zeile %d", 
               xml_error_string(xml_get_error_code($this->hdlParser)),
               xml_get_current_line_number($this->hdlParser));
        ## Anschliessend wird der Fehler übersprungen.
        while ($this->avoid_error($this->hdlDataStructure));
      }
      flush();
    }
    ## Schliessen der Quelldatei
    fclose($this->hdlDataStructure);
    echo "<p>Einlesen der Topics beendet...</p>";
    ## Schliessen des XML-Parsers
    xml_parser_free($this->hdlParser);
  }
  
  ## Die Funktion "parse_xml_topics_update" ist fats gleich wie die Funktion
  ## "parse_xml_topics" aufgebaut.. Sie stellt auf Grundlage der bereits 
  ## importierten Elemente die Verknüpfung zu den "Eltern-Elementen" her.
  function parse_xml_topics_update()
  {
    xml_set_element_handler($this->hdlParser, "startElement", "endElement");
    xml_set_character_data_handler($this->hdlParser, "charData");
    $strStructure           = STRUCTURE;
    ## Datei zuruecksetzen und erneut zur Aktualisierung einlesen
    $this->hdlDataStructure = fopen($strStructure, "r");
    $this->blnUpdate        = TRUE;
    echo "<p>Beginne Update der Daten...</p>";
    ## Updaten mit den Verweisen der Narrows auf die Topics
    while($strXMLData = fgets($this->hdlDataStructure, 4096))
    {
      if(!xml_parse($this->hdlParser, $strXMLData, feof($this->hdlDataStructure)))
      {
        printf("<br>XML Fehler: %s in Zeile %d", 
               xml_error_string(xml_get_error_code($this->hdlParser)), 
               xml_get_current_line_number($this->hdlParser));
        while($this->avoid_error($this->hdlDataStructure));
      }
    }
    fclose($this->hdlDataStructure);
    echo "<p>Update der Topics beendet...</p>";
    xml_parser_free($this->hdlParser);
  }
  
  ## Auf dieselbe Art ist die Funktion "parse_xml_content" aufgebaut, die
  ## den Inhalt importiert.
  function parse_xml_content()
  {
    $this->blnUpdate = FALSE;
    xml_set_element_handler($this->hdlParser, "startElement", "endElement");
    xml_set_character_data_handler($this->hdlParser, "charData");
    $strContent = CONTENT;
    $this->hdlDataContent = fopen($strContent, "r");
    ## Einlesen aller Links
    echo "<p>Beginne Import der Inhaltsdaten...</p>";
    while ($strXMLData = fgets($this->hdlDataContent, 4096))
    {
      if(!xml_parse($this->hdlParser, $strXMLData, feof($this->hdlDataContent)))
      {
        printf("<br>XML Fehler: %s in Zeile %d", xml_error_string(xml_get_error_code($this->hdlParser)), xml_get_current_line_number($this->hdlParser));
        while($this->avoid_error($this->hdlDataContent));
      }
    }
    fclose($this->hdlDataContent);
    echo "<p>Einlesen des Contents beendet...</p>";
    xml_parser_free($this->hdlParser);
    ## Datei zuruecksetzen und erneut zur Aktualisierung einlesen
  }
}
?>

Importskripte

Die in der Datei "open_xmplproject.inc.php" definierte Klasse "import_dmoz" wird in den folgenden drei Skripten verwendet.

  • "import_topic.php" importiert die Topics.
  • "import_topic_update.php" stellt die Verknüpfungen her.
  • "import_content.php" importiert den Inhalt.
<?php
## Name     import_topic.php

include("open_xmlproject.inc.php");
ini_set("max_execution_time", 3600);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>Import DMOZ</title>
</head>
<body>
<?php
ob_end_flush();
echo "<p>Vorbereitung...</p>";
## Erzeugen der Tabelle, löschen der alten
create_table_topics();
## Import der Daten
$clsDmoz = new import_dmoz;
$clsDmoz->parse_xml_topics();
?>
<p>Done...</p>
<p><a href="import.php">Zurück zur Import-Startseite</a></p>
</body>
</html>
<?php
## Name     import_topic_update.php
include("open_xmlproject.inc.php");
ini_set("max_execution_time", 7200);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>Import DMOZ</title>
</head>
<body>
<?php
ob_end_flush();
echo "<p>Vorbereitung...</p>";
## Import der Daten
$clsDmoz = new import_dmoz;
$clsDmoz->parse_xml_topics_update();
?>
<p>Done...</p>
<p><a href="import.php">Zurück zur Import-Startseite</a></p>
</body>
</html>
<?php
## Name     import_content.php

include("open_xmlproject.inc.php");
ini_set("max_execution_time", 3600);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>Import DMOZ-Content</title>
</head>
<body>
<?php
ob_end_flush();
echo "<p>Vorbereitung...</p>";
## Erzeugen der Tabelle, löschen der alten
create_table_content();
## Import der Daten
$clsDmoz = new import_Dmoz;
$clsDmoz->parse_xml_content();
?>
<p>Done...</p>
<p><a href="import.php">Zurück zur Import-Startseite</a></p>
</body>
</html>

Alle drei Skripte können bequem über das Skript "import.php" erreicht werden. Die Skripte rufen die Datei "open.inc.php", welche die Klasse "import_dmoz" enthält.

<?php
## Name     import.php

include("open_xmlproject.inc.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>Import der DMOZ-Daten</title>
  <link rel="stylesheet" type="text/css" href="php.css">
</head>
<body bgcolor="#eeeeee">
<h1>Import der DMOZ-Daten</h1>
<h3>Import ausführen</h3>
<div class=text>
Um das komplette Verzeichnis zu importieren, müssen Sie Änderungen an der Konfiguration der Datei <b><code>/etc/php5/apache2/php.ini</code></b> vornehmen:
<p>
<ul>
  <li><code>max_execution_time = 14400</code>: Ausführungszeit des Skripts 4 Stunden
  <li><code>memory_limit = 168M</code>: Speicherlimit 168 MB
</ul>
Starten Sie dann nacheinander die folgenden drei Skripte. Die Abarbeitung kann je nach Hardware mehrere Stunden betragen.
<p>
<ul>
  <li><a href="import_topic.php">Kategorien importieren</a> (15-45 min)
  <li><a href="import_content.php">Inhalte importieren</a> (15-45 min)
  <li><a href="import_topic_update.php">Verknüpfungen herstellen</a> (2-3 Stunden)
</ul>
</div>
</body>
</html>

Die Stammfunktionen

<?php
## Name     search_xmlproject.php

class MySQL  {
  var $CONNECTION  = "";
  var $DATABASE    = "php5test";
  var $USER        = "root";
  var $PASSWORD    = "";
  var $SERVER      = "localhost";
  
  var $TRAIL       = array();
  var $HITS        = array();
  
  var $AUTOAPPROVE = true;
  
  function error($text)
  {
    $no  = mysql_errno();
    $msg = mysql_error();
    echo "[$text] ( $no : $msg )<br />\n";
    exit;
  }

  function init ()
  {
    $user       = $this->USER;
    $password   = $this->PASSWORD;
    $server     = $this->SERVER;
    $database   = $this->DATABASE;
    $connection = mysql_connect($server, $user, $password);
    if (!$connection)
    {
      $this->error("Verbindungsfehler ");
    }
    if (!mysql_select_db($database, $connection)) {
      $this->error("Datenbankfehler");
    }
    $this->CONNECTION = $connection;
    return true;
  }
  
##### MySQL-spezifische Methoden #####
  
  function select ($sql = "")
  {
    if (empty($sql))
    {
      return false;
    }
    if (!eregi("^select", $sql))
    {
      echo "<h2>Wrong function silly!</h2>\n";
      return false;
    }
    if (empty($this->CONNECTION))
    {
      return false;
    }
    $connection = $this->CONNECTION;
    $results    = mysql_query($sql, $connection);
    if ( (!$results) or (empty($results)) )
    {
      @mysql_free_result($results);
      return false;
    }
    $count = 0;
    $data = array();
    while ($row = mysql_fetch_array($results))
    {
      $data[$count] = $row;
      $count++;
    }
    mysql_free_result($results);
    return $data;
  }

##### phpDmoz-spezifische Methoden #####

  function get_Cats ($catparent= "")
  {
    if (empty($catparent))
    {
      $catparent = 0;
    }
    $sql      = "SELECT topic_id AS catid, topic_title AS catname FROM topic ";
    $sql     .= " WHERE topic_parent=$catparent ORDER BY topic_title";
    $results  = $this->select($sql);
    return $results;
  }
  
  ## The primer for a recursive query
  function get_ParentsInt($catid = "")
  {
    if(empty($catid))
    {
      return false;
    }
    unset($this->TRAIL);
    $this->TRAIL = array();
    $this->get_Parents($catid);
    }
  
  ## Use get_ParentsInt(), NOT this one!
  ## The power of recursive queries
  function get_Parents ($catid = "") 
  {
    if ((empty($catid)) or ($catid == NULL)) 
    { 
      return false; 
    }
    $sql      = "SELECT topic_id AS catid, topic_parent AS catparent, topic_title AS catname from topic";
    $sql     .= " WHERE topic_id = $catid";
    $results  = mysql_query($sql, $this->CONNECTION);
    if( (!$results) or (empty($results)) ) 
    {
      return false;
    }
    while ($row = mysql_fetch_array($results))   
    {
      $trail         = $this->TRAIL;
      $count         = count($trail);
      $trail[$count] = $row;
      $this->TRAIL   = $trail;
      $id            = $row["catparent"];
      $this->get_Parents($id);
    }
    return true;
  }
  
  function get_CatIDFromName($catname="")   
  {
    if (empty($catname))
    {
      return false;
    }
    $sql     = "SELECT topic_id AS catid from topic WHERE topic_title = \"$catname\"";
    $results = $this->select($sql);
    if (!empty($results))
    {
      $results = $results[0]["catid"];
    }
      return $results;
  }
  
  function get_CatNames( $catid = "")    
  {
    if($catid == 0) 
    { 
      return "Top"; 
    }
    if (!empty($catid))
    {
      $sql     = "SELECT topic_title AS catname FROM topic WHERE topic_id = $catid";
      $results = $this->select($sql);
      if (!empty($results)) 
      {
        $results = $results[0]["catname"];
      }
    }
    return $results;
  }
  
  function get_Links($catid = "") 
  {
    if (empty($catid)) 
    {
      $catid = 0;
    }
    $sql      = "SELECT content_page AS url, content_title AS linkname, content_desc AS description FROM content";
    $sql     .= " WHERE topic_id = $catid ORDER BY content_page";
    $results  = $this->select($sql);
    return $results;
    }
  
  function get_CatFromLink($linkid = "")
  {
    if (empty($linkid))
    {
      return false;
    }
    $sql     = "SELECT topic_id AS catid FROM content WHERE id = $linkid";
    $results = $this->select($sql);
    if (!empty($results))
    {
      $results = $results[0]["catid"];
    }
    return $results;
  }
  
  function search ($keywords = "")
  {
    if (empty($keywords))
    {
      return false;
    }
    $keywords = trim(urldecode($keywords));
    $keywords = ereg_replace("([    ]+)"," ",$keywords);
    if (!ereg(" ", $keywords))
    {
      ## Only 1 keyword
      $keywords[0] = "$keywords";
    }
    else
    {
      $keywords = explode(" ", $keywords);
    }
    $sql    = "SELECT DISTINCT id AS linkid, topic_id AS catid, content_page AS url,";
    $sql   .= " content_title AS linkname, content_desc AS description FROM content WHERE (";
    $count  = count($kewords);
    if( $count == 1)
    {
      $single  = $keywords[0];
      $sql    .= " (content_desc  LIKE \"%$single%\") OR";
      $sql    .= " (content_title LIKE \"%$single%\") OR";
      $sql    .= " (content_page  LIKE \"%$single%\") ) ORDER BY content_title";
    }
    else
    {
      $ticker = 0;
      foreach ($keywords as $key => $word)
      {
        $ticker++;
        if (!empty($word))
        {
          if($ticker != $count)
          {
            $sql .= " (  (content_desc  LIKE \"%$word%\")";
            $sql .= " OR (content_title LIKE \"%$word%\")";
            $sql .= " OR (content_page  LIKE '%$word%') ) AND";
            }
          else
          {
             ## Last condition, omit the trailing AND
             $sql .= " (  (content_desc  LIKE \"%$word%\")";
             $sql .= " OR (content_title LIKE \"%$word%\")";
             $sql .= " OR (content_page  LIKE \"%$word%\") )";
          }
        }
      }
      $sql .= " ) ORDER BY content_title";
    }
    $results = $this->select($sql);
    return $results;
  }
}
?>

Die Benutzeroberfläche

Nach dem Import der Daten kann das angepasste phpHoo-Skript "main_xmlproject.php" verwendet werden.

<?php
## Name         main_xmlproject.php
## Description  Auf Grundlage von phpHoo

include("search_xmlproject.php");

$db = new MySQL;
if (!$db->init())
{
  die("Ein Fehler ist aufgetreten<br />\n");
}
  
function breadcrumbs($CatID="") {
  global $db;
  global $PHP_SELF;
  
  if (empty($catid))
  {
    return;
  }
  $db->get_ParentsInt($catid);
  $path = $db->TRAIL;
  if (!empty($path))
  {
    $trail = "";
    foreach($path as $key => $val)
    {
      $catid    = stripslashes($val["catid"]);
      $catname  = stripslashes($val["catid"]);
      $trail    = "|<a href=\"$PHP_SELF?viewcat=$catid\"><b>$catname</b></a>$trail";
    }
  }
  else
  {
    $trail = "";
  }
  return $trail;
}
  
function start_page($catid="", $title="", $msg="")
{
  global $PHP_SELF;
  echo <<<HEADA
  <html>
  <head>
    <title>phpDmoz - $title</title>
  </head>
  <body bgcolor="#FFFFFF" text="#000000" link="#0033FF" vlink="#660099">
  <center><h1>phpDmoz</h1></center>
HEADA;
  if (!empty($msg)) {
    echo "\n<center><b>$msg</b></center>\n";
  }
  echo <<<HEADB
  <center><form action="{$_SERVER['PHP_SELF']}" method="post">
    <input type ="text" name="keywords" size=20>
    <input type="submit" name="search" value="Search"></form></center>
    <p><h3>Suchpfad
HEADB;
  $trail = breadcrumbs($catid);
  echo "$trail</h3></p>\n<hr>\n";
  return;
}
  
function start_browse($catid = "") {
  global $PHP_SELF;
  global $db;
  $data   = $db->get_Cats($catid);
  $links  = $db->get_Links($catid);
  if (!empty($catid))
  {
    $currentid   = $catid;
    $currentname = $db->get_CatNames($catid);
  }
  else
  {
    $currentid   = "top";
    $currentname = "top";
  }
  if (is_array($data))
  {
    foreach($data as $key => $val)
    {
      $catid   = stripslashes($val["catid"]);
      $catname = stripslashes($val["catname"]);
      print "<li><a href=\"$PHP_SELF?viewcat=$catid\"><b>$catname</b></a></li>\n";
    }
  } 
  echo "<hr>\n";
  if (is_array($links))
  {
    foreach ($links as $key => $val)
    {
      $url      = stripslashes($val["url"]);
      $linkname = stripslashes($val["linkname"]);
      $desc     = stripslashes($val["description"]);
      print "<li><a href=\"$url\"><b>$linkname</b></a> - $desc</li>\n";
    }
  }
  return;
}

#####

if (isset($_GET['viewcat']))
{
  start_page($_GET['viewcat']);
  start_browse($_GET['viewcat']);
  exit;
} 
elseif (isset($_POST['keywords'])) 
{
  $hits = $db->search($_POST['keywords']);
  if( (!$hits) or (empty($hits)) ) 
  {
    $junk  = "";
    $title = "Suchergebnisse";
    $msg   =  "Keine Seiten gefunden";
    start_page($junk, $title, $msg);
  } 
  else 
  {
    $total = count($hits);
    $title = "Suchergebnisse";
    $msg   = "Die Suche ergab [$total] Treffer";
    $junk  = "";
    start_page($junk, $title, $msg);
    foreach($hits as $key => $hit) 
    {
      if(!empty($hit))
      {
        $linkid   = $hit["linkid"];
        $linkname = stripslashes($hit["linkname"]);
        $linkdesc = stripslashes($hit["description"]);
        $linkurl  = stripslashes($hit["url"]);
        $catid    = $hit["catid"];
        $catName  = stripslashes($db->get_CatNames($catid));
        print "<dl>\n";
        print "<dt><a href=\"$linkurl\" target=\"_NEW\">$linkname</a>\n";
        print "<dd>$linkdesc\n";
        print "<dd><b>Gefunden in Kategorie</b>&nbsp;<a href=\"$PHP_SELF?viewcat=$catid\">$catname</a>\n";
        print "</dl>\n";
      }
    }
  }
  echo "<p><hr>\n";
  start_browse();
  exit;
}
else
{
  start_page(1);
  start_browse(1);
  exit;
}
?>