Re: simple xml api

From: Date: Sun, 02 Feb 2003 05:16:27 +0000
Subject: Re: simple xml api
References: 1 2  Groups: php.xml.dev 
Request: Send a blank email to php-xml-dev+get-25@lists.php.net to get a copy of this message
From reading through the notes, I think this Simple XML API is a great idea and will make xml document parsing just as easy as parsing an associative array. A couple notes: I think accessing attributes via associative arrays would be better only because a node could have a attribute and a child node of the same name, so if $simple->name->length was used, distinguishing them wouldn't be possible, such as: <simple> <name length="4"> <length>2</length> </name> </simple> Also, I think it would be great if we could build up new (or edit existing) xml structures using this new API and then dump it back into a xml string. I was previously using domxml to build up new xml streams, but I recently switched to string concats because I didn't need all the domxml features and I noticed a slowdown in script execution under high loads with domxml - so something like this Simple XML API that will take care of converting the object back into valid xml would be perfect. Ryan "Sterling Hughes" <sterling@bumblebury.com> wrote in message news:1044021310.15188.3222.camel@hasele... > On Fri, 2003-01-31 at 05:55, Christian Stocker wrote: > > On Thu, 2003-01-30 at 18:18, Sterling Hughes wrote: > > > Sam Ruby sent me the following URL: > > > http://dev2dev.bea.com/articlesnews/discussion/thread.jsp?thread=JSchneider_ XML > > > > > > It looks really neat, and much in the PHP way of doing things. Take the > > > following XML document, and I'll show you how easy parsing it is with > > > the Simple API proposed above (ported slightly to PHP). > > > > IMHO, it's a nice way to approach XML documents which are relatively > > shallow like the example below (data centric XML-docs). But I wouldn't > > want to process something Docbook-style with that :) And how does it > > handle attributes, comments, processing instructions, namespaces, etc.? > > > > You would want to process something like docbook? :-) > > attributes and namespaces are just another level of indirection. ie: > > <php.dev> > <php.dev.xml>cool</php.dev.xml> > </php.dev> > > var_dump($php->dev->xml); > // string (4) "cool" > > and > > <simple> > <name length="4">John</name> > </simple> > > var_dump($simple->name->length); > // int (4) > var_dump($simple->name); > // string (4) "John" > > Or we could make them associative array accesses: > > var_dump($simple->name['length']); > // int (4) > > Processing instructions could be per node arrays. Remember, since we're > overloading we can do some magic here. Comments could be in a "special" > array $node->__comments. > > > > So, it would be certainly a nice additon to DOM/SAX/XSLT, but it can't > > provide a replacement for them (again IMHO...) > > Agreed. But what I like about is that its a much simplified subset of > 95% of what most people want to do. > > -Sterling > > -- > "The computer programmer is a creator of universes for which he > alone is responsible. Universes of virtually unlimited complexity > can be created in the form of computer programs." > - Joseph Weizenbaum >

« previous php.xml.dev (#25) next »