Skip to Main Content
PHP 5 Kochbuch, Third Edition
book

PHP 5 Kochbuch, Third Edition

by David Sklar, Adam Trachtenberg, Carsten Lucke, Matthias Brusdeylins, Ulrich Speidel, Stephan Schmidt
September 2009
Intermediate to advanced content levelIntermediate to advanced
912 pages
48h 11m
German
O'Reilly Verlag
Content preview from PHP 5 Kochbuch, Third Edition

14.11 Informationen aus einem XML-Dokument selektieren (XPath)

Problem

Sie möchten auf einfache Art auf bestimmte Informationen in einem XML-Dokument abhängig von Tag-Namen und Attributwerten zugreifen.

Lösung

Verwenden Sie die XPath-Funktionen der DOM-Erweiterung, um einzelne Knoten zu extrahieren und weiterzuverarbeiten.

$xml = <<<EOD <team name="JLA"> <held alias="Superman"> <name>Clark Kent</name> <stadt>Metropolis</stadt> </held> <held alias="Batman"> <name>Bruce Wayne</name> <stadt>Gotham City</stadt> </held> <held alias="Der Rote Blitz"> <name>Wally West</name> <stadt>Keystone City</stadt> </held> </team> EOD; // Neues Dokument erzeugen. $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; // XML parsen. $dom->loadXML($xml); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP programmieren unter Windows

PHP programmieren unter Windows

Arno Hollosi
CSS Kochbuch, 3rd Edition

CSS Kochbuch, 3rd Edition

Joergen Lang, Christopher Schmitt

Publisher Resources

ISBN: 9783868993271Purchase book