Sitellite Application Framework
Class Tree         Index         All Elements

Class: SloppyDOM

Source Location: Program_Root/XML/Sloppy.php

Class Overview


SloppyDOM is a lightweight XML parser that creates an in-memory copy of the XML document using the XMLDoc class. This allows lightweight document parsing and modifications to take place. Note: does not maintain DOCTYPE declarations and comments (hence Sloppy).


Author(s)

Version

  • 2.8, 2002-10-10, $Id: Sloppy.php,v 1.3 2005/10/16 02:52:14 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 87]
SloppyDOM is a lightweight XML parser that creates an in-memory copy of the XML document using the XMLDoc class. This allows lightweight document parsing and modifications to take place. Note: does not maintain DOCTYPE declarations and comments (hence Sloppy).

New in 1.2:

  • Added support for CDATA blocks.
New in 1.4:
  • Fixed a small bug that caused parsing to hang on multi-line comments.
New in 2.0:
  • Rewrote the class to use the PHP expat extension (like it should have from 1.0), so it's much faster and more stable now. It's also backward-compatible with 1.x.
  • Also added the parseFromFile() method, and the $encoding property, which specifies the type of encoding to send to the internal expat parser. ISO-8859-1 is the default, and US-ASCII and UTF-8 are also supported.
  • Added the following properties, which hold information pertaining to parsing errors: $error, $err_code, $err_line, $err_byte, and $err_column.
New in 2.2:
  • Fixed a spacing issue with parsing then resaving XML files, where extra space was being added each time a file is edited.
New in 2.4:
  • Changed parseFromFile() to set the XMLDoc's $filename property before returning the object. Also improved error handling slightly in that method.
New in 2.6:
  • Added an optional $cacheFile parameter to parseFromFile(), which works with XMLDoc's cache() method to make caching an XML document effortless.
New in 2.8:
  • Fixed some things that were causing allow_call_time_pass_by_reference (or something like that) warnings.

1 <?php
2
3 $sd = new SloppyDOM ();
4
5 if ($new_doc = $sd->parse ($xml_data)) {
6 // use $new_doc
7 } else {
8 echo $sd->error;
9 }
10
11 ? >




Tags:

access:  public
version:  2.8, 2002-10-10, $Id: Sloppy.php,v 1.3 2005/10/16 02:52:14 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$comment =

[line 169]

The contents of the current comment tag.



Tags:

access:  public

Type:   mixed


[ Top ]

$doc =

[line 135]

The XMLDoc object that was last parsed.



Tags:

access:  public

Type:   mixed


[ Top ]

$encoding =

[line 161]

The optional encoding type to use when creating the XML parser resource.



Tags:

access:  public

Type:   mixed


[ Top ]

$error =

[line 95]

Will contain the error message in the event of a parsing error, or false otherwise, so that it can be used in an if (error) statement.



Tags:

access:  public

Type:   mixed


[ Top ]

$err_byte =

[line 119]

Will contain the error byte index in the event of a parsing error.



Tags:

access:  public

Type:   mixed


[ Top ]

$err_code =

[line 103]

Will contain the error code in the event of a parsing error.



Tags:

access:  public

Type:   mixed


[ Top ]

$err_colnum =

[line 127]

Will contain the error column number in the event of a parsing error.



Tags:

access:  public

Type:   mixed


[ Top ]

$err_line =

[line 111]

Will contain the error line in the event of a parsing error.



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor SloppyDOM [line 178]

SloppyDOM SloppyDOM( [string $encoding = 'ISO-8859-1'])

Constructor method.



Tags:

access:  public


Parameters:

string   $encoding  

[ Top ]

method parse [line 245]

object parse( string $data)

Parses a string of XML data and returns an XMLDoc object representation of it.

Note: Returns false on failure.




Tags:

access:  public


Parameters:

string   $data  

[ Top ]

method parseFromFile [line 205]

object parseFromFile( string $filename, [string $cacheFile = ''])

Parses a string of XML data and returns an XMLDoc object representation of it.

Note: Returns false on failure. If you include the name of a $cacheFile, parseFromFile() will compare its file modification time to the mod time of the original file and use the cached copy if the original has not been modified. This means that a document can be cached using XMLDoc's cache() method, and then only have to be parsed once after any change is made. Since parsing XML can be a memory intensive process, especially on larger documents, having the luxury of not parsing the same document upon each visitor request makes it much more appealing to use XML in web applications. Even XML configuration files are not unreasonable (although you want to be careful not to cache a configuration file within the document root of your site!!!). Cache files are simply serialized XMLDoc objects.




Tags:

access:  public


Parameters:

string   $filename  
string   $cacheFile  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:19:32 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2