Overview There are many PHP XML tutorials on the Internet, but only a few show how to use DOM to resolve XML. I want to use this opportunity to show another option in addition to the widely used SAX implementation in PHP programming.
DOM (Document Object Model, Document Object Model) and SAX (Simple API for XML, XML Simple Applications) have different methods on how to resolve XML. The SAX engine is entirely the event driven. When it encounters a tag, it calls an appropriate function to handle it. This makes SAX very quickly and effective. However, he feels like it is in a set of incompetent circles. You find that you use too much global variables and conditional statements.
On the other hand, the DOM method is slightly sensitive to memory. It loads the entire XML document in a hierarchical structure. That is to say, all data form a family tree, and they are available for programming. This method is more intuitive and easier to use, and more readability is also provided.
In order to use the DOM function, you must use the '--with-dom' parameter when configuring the PHP. They are not part of the standard configuration, where there is a simple compilation.
%> ./Configure --with-dom --with-apache = .. / apache_1.3.12%> Make%> make install
Translation: Supporting the DOM practice on the Win32 platform is like this. First, copy the php_domxml.dll file under the DLLS directory in the download package to the system directory. NT, Win2k is the System32 directory, and 9x is the system directory. Second, modify the php.ini file. Point the extension_dir parameter in "Paths and Directories" to PHP_DOMXML.DLL, such as extension_dir = c: / winnt / system32; remove "Dynamic Extensions" = php_domxml.dll before the comment.
How to construct XML
Because the DOM loads a complete string or file to memory as a tree, this allows us to operate as a whole. We take this XML document as an example.
XML Version = "1.0"?>
Data will be organized like this
Domnode book || -> Domnode Title | || | -> Domnode text || -> Domnode Price | || | -> Domnode Text || -> Domnode Author || -> Domnode Name || -> Domnode BirthDate || -> Domnode Text
Any text that is labeled is all nodes they own. For example, "Red Nails" is a child node of Title, "$ 12.99" is the child's child node. 1 2 3 Next Page