note 42179 added to ref.xml
| From: | moc dot oohay at mijito dot php dot net | Date: | Thu, 06 May 2004 14:21:25 +0000 |
| Subject: | note 42179 added to ref.xml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69280@lists.php.net to get a copy of this message | ||
I found a type-o in the XMLTag->addChild function. I re-examined the code and changed the
function so it is a little cleaner.
Also, as an interesting side-note. I ran the script on a 1 MB XML file. The php.exe memory usage
exceeded 50 MB during runtime. I did a print_r($XML_data) dumping into a plain-text file which
resulted in a 70 MB text file. However, after I removed all the [spaces] used for formatting and
readability the file size was reduced to 5 MB.
This script may not be efficient for very large data sets. ;)
I am very pleased that the script parsed the file without error. A very successful "real
world" test.
Repaired addChild:
function addChild($XMLTag_obj) {
$key = $XMLTag_obj->name;
// If this tag *name* is not already a child initialize it.
if ( !isset($this->children[$key][0]) ) {
$this->children[$key][0] = 0;
}
// Get the next array index. This is the next available location to store the child
$index = $this->children[$key][0] + 1;
// Add the child and update the tag count
$this->children[$key][$index] = $XMLTag_obj;
$this->children[$key][0]++;
// Return the Child Tag
return $this->children[$key][$index];
}
----
Manual Page -- http://www.php.net/manual/en/ref.xml.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42179
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42179&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42179&report=yes
Search -- http://master.php.net/manage/user-notes.php