summaryrefslogtreecommitdiff
path: root/ext/tidy/examples
diff options
context:
space:
mode:
authorJohn Coggeshall <john@php.net>2003-09-22 18:40:38 +0000
committerJohn Coggeshall <john@php.net>2003-09-22 18:40:38 +0000
commitd8eeb8e28673236bca3f066ded75037a5bdf6378 (patch)
tree86098c5a695e81f72741d5c9d6ade955c6491fbd /ext/tidy/examples
parent6b567f80c7ffc57957107949f90080d7bcb24744 (diff)
downloadphp-git-d8eeb8e28673236bca3f066ded75037a5bdf6378.tar.gz
Updated test cases and examples and cleaned up the new OO code so it will
be easier to maintain.
Diffstat (limited to 'ext/tidy/examples')
-rw-r--r--ext/tidy/examples/cleanhtml.php16
-rw-r--r--ext/tidy/examples/dumpit.php14
-rw-r--r--ext/tidy/examples/urlgrab.php15
3 files changed, 19 insertions, 26 deletions
diff --git a/ext/tidy/examples/cleanhtml.php b/ext/tidy/examples/cleanhtml.php
index c949a0cfc2..9d054cda4f 100644
--- a/ext/tidy/examples/cleanhtml.php
+++ b/ext/tidy/examples/cleanhtml.php
@@ -12,26 +12,24 @@
*
*/
- $tidy = tidy_create();
-
if(!isset($_SERVER['argv'][1])) {
$data = file_get_contents("php://stdin");
- tidy_parse_string($tidy, $data);
+ tidy_parse_string($data);
} else {
- tidy_parse_file($tidy, $_SERVER['argv'][1]);
+ tidy_parse_file($_SERVER['argv'][1]);
}
- tidy_clean_repair($tidy);
+ tidy_clean_repair();
- if(tidy_warning_count($tidy) ||
- tidy_error_count($tidy)) {
+ if(tidy_warning_count() ||
+ tidy_error_count()) {
echo "\n\nThe following errors or warnings occured:\n";
- echo tidy_get_error_buffer($tidy);
+ echo tidy_get_error_buffer();
echo "\n";
}
- echo tidy_get_output($tidy);
+ echo tidy_get_output();
?>
diff --git a/ext/tidy/examples/dumpit.php b/ext/tidy/examples/dumpit.php
index 46d307d704..e0cda5e904 100644
--- a/ext/tidy/examples/dumpit.php
+++ b/ext/tidy/examples/dumpit.php
@@ -10,15 +10,13 @@
* Usage; php dumpit.php <filename>
*/
-
- $tidy = tidy_create();
- tidy_parse_file($tidy, $_SERVER['argv'][1]);
+ tidy_parse_file($_SERVER['argv'][1]);
/* Optionally you can do this here if you want to fix up the document */
- /* tidy_clean_repair($tidy); */
+ /* tidy_clean_repair(); */
- $tree = tidy_get_root($tidy);
+ $tree = tidy_get_root();
dump_tree($tree);
echo "\n";
@@ -70,12 +68,12 @@
}
/* Any attributes on this node? */
- if(count($node->attribs)) {
+ if(count($node->attributes())) {
do_leaf(" |\n", $indent);
do_leaf(" +---- Attributes\n", $indent);
/* Cycle through the attributes and display them and their values. */
- foreach($node->attribs as $attrib) {
+ foreach($node->attributes() as $attrib) {
do_leaf(" +--{$attrib->name}\n", $indent);
do_leaf(" | +-- Value: {$attrib->value}\n", $indent);
}
@@ -83,7 +81,7 @@
/* Recurse along the children to generate the remaining nodes */
if($node->has_children()) {
- foreach($node->children as $child) {
+ foreach($node->children() as $child) {
dump_tree($child, $indent + 3);
}
}
diff --git a/ext/tidy/examples/urlgrab.php b/ext/tidy/examples/urlgrab.php
index 63a2875a79..7896792ea5 100644
--- a/ext/tidy/examples/urlgrab.php
+++ b/ext/tidy/examples/urlgrab.php
@@ -11,18 +11,15 @@
* Usage: php urlgrab.php <file>
*
*/
-
- /* Create a Tidy Resource */
- $tidy = tidy_create();
-
+
/* Parse the document */
- tidy_parse_file($tidy, $_SERVER['argv'][1]);
+ tidy_parse_file($_SERVER['argv'][1]);
/* Fix up the document */
- tidy_clean_repair($tidy);
+ tidy_clean_repair();
/* Get an object representing everything from the <HTML> tag in */
- $html = tidy_get_html($tidy);
+ $html = tidy_get_html();
/* Traverse the document tree */
print_r(get_links($html));
@@ -33,7 +30,7 @@
/* Check to see if we are on an <A> tag or not */
if($node->id == TIDY_TAG_A) {
/* If we are, find the HREF attribute */
- $attrib = $node->get_attr_type(TIDY_ATTR_HREF);
+ $attrib = $node->get_attr(TIDY_ATTR_HREF);
if($attrib) {
/* Add the value of the HREF attrib to $urls */
$urls[] = $attrib->value;
@@ -45,7 +42,7 @@
if($node->has_children()) {
/* Traverse down each child recursively */
- foreach($node->children as $child) {
+ foreach($node->children() as $child) {
/* Append the results from recursion to $urls */
foreach(get_links($child) as $url) {