note 39584 added to ref.xml

From: Date: Tue, 03 Feb 2004 07:27:53 +0000
Subject: note 39584 added to ref.xml
Groups: php.notes 
Request: Send a blank email to php-notes+get-64584@lists.php.net to get a copy of this message
I have created a class set that both parses XML into an object structure and from that structure creates XML code. It is mostly finished but I thought I would post here as it may help someone out or if someone wants to use it as a base for their own parser. The method for creating the object is original compared to the posts before this one. The object tree is created by created seperate tag objects for each tag inside the main document object and associating them together by way of object references. An index table is created so that each tag is assigned an ID number (in numerical order from 0) and can be accessed directly using that ID number. Each tag has object references to its children. There are no uses of eval() in this code. The code is too long to post here, so I have made a HTML page that has it: http://www.withouthonor.com/obj_xml.html Sample code would look something like this: <? $xml = new xml_doc($my_xml_code); $xml->parse(); $root_tag =& $xml->xml_index[0]; $children =& $root_tag->children; // and so forth // To create XML code using the object, would be similar to this: $my_xml = new xml_doc(); $root_tag = $my_xml->CreateTag('ROOTTAG'); $my_xml->CreateTag('CHILDTAG',array(),'',$root_tag); // The following is used for the CreateTag() method // string Name (The name of the child tag) // array Attributes (associative array of attributes for tag) // string Content (textual data for the child tag) // int ParentID (Index number for parent tag) // To generate the XML, use the following method $out_xml = $my_xml->generate(); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.xml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39584 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39584&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39584&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64584) next »