> My thoughts on this are as follows, some are directly related to the
topic,
> some are related to simplexml's original design and current functionality.
> SimpleXML was originally designed to provide a direct mapping between a
> XML document and a data structure, through access to the properties and
> attributes and *only* the properties and attributes.

What's the ultimate goal for simpleXML? I have been hesitant from ever
touching this extension as what I thought it was intended to do, seems
simplistic to where it acutally (is going/went?). Correct me if I'm wrong,
but when it started I thought simpleXML's intent was to handle XML
structures containing only elements and attributes (or at least ignoring
everything else). The structure could never contain an element which had an
attribute named the same as one of its child elements (otherwise you would
need to be adding functionality as well to distinguish when you work with
the attribute or element). Also, elements would contain either text or
children elements but not both.

Not sure about how adding one of these types was to be handled as you would
need a way to determine wether you are adding an element or an attribute.

As I said, this may be a simplistic view, but as it evolved, I just dont
understand the concept behind simpleXML anymore.

> 3) For the next version of PHP, PHP5.1 add a new xpath extension which
> provides a generic query interface to XML objects.  This would be
> something like:
>
> if (xpath_query('/child::node()', $node, $results)) {
> }
>
> As xpath is very much akin to regular expressions for XML.  This is a
> more elegant solution than the current DOM api for XML which would
> require a casting into a dom object, then a domxpath object, then a
> simplexml object. (*)

There is a problem here however as simpleXML can only handle Element,
Attribute and Text nodes, so if any other node type is returned in the
nodelist there will be problems. simpleXML will need a custom xpath handler
to insure that the returned nodes are of type element or attribute.

The dom api for xpath also wasnt meant as the end all solution either. It
was a quick implementation to at least support querying nodes in the
document, but thats about all it does. The majority of XPath functionality
wasnt touched.

I do agree with the comment that DOM is big and clunky. In reality, I have
only ever had to use a handful of its functions and the only reason it got
done is that people using domxml wanted a compliant implementation that
implemented the functionality correctly and I had time to kill. Personally I
would like a simpleXML/DOM hybrid extension which took some of the best
features of each, so would offer the ease of use of simpleXML, some of the
more advanced features/methods in dom, yet noy have all the dom api baggage.

Rob

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to