Skip to Main Content
XML and PHP
book

XML and PHP

by Vikram Vaswani
June 2002
Intermediate to advanced content levelIntermediate to advanced
384 pages
7h 53m
English
Sams
Content preview from XML and PHP

Traversing the DOM with PHP’s DOM Classes

Because PHP’s DOM parser works by creating standard objects to represent XML structures, an understanding of these objects and their capabilities is essential to using this technique effectively. This section examines the classes that form the blueprint for these objects in greater detail.

DomDocument Class

A DomDocument object is typically the first object created by the DOM parser when it completes parsing an XML document. It may be created by a call to xmldoc():

$doc = xmldoc("<?xml version='1.0'?><element>potassium</element>"); 

Or, if your XML data is in a file (rather than a string), you can use the xmldocfile() function to create a DomDocument object:

$doc = xmldocfile("element.xml"); 

Treading ...

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 Development Tool Essentials

PHP Development Tool Essentials

Chad Russell
PHP Web Services

PHP Web Services

Lorna Jane Mitchell

Publisher Resources

ISBN: 0735712271Purchase book