Adam Trachtenberg wrote:
Ugh. This is pretty much the limit of what I think is reasonable for SimpleXML to handle. It think the API would be more consistent if the

Agreed. I was just curious how it behaves if I push it to the limit :-)


> However, I don't really see any way around this otherwise. Either it's
>  general or not. It can't be both. (Unless there's some magical type
> that's both an array and a scalar.) I'm willing to put up with this

Elements are already a magical type which is an object and an array.
Making foreach work on a both the scalar and array incantation of child elements seems very useful to me. And usefulness seems to be the goal of SimpleXML as far as I understand.


maxOccurs attributes in the schema for an element. If maxOccurs > 1, then the elements would be placed in an array even if there was only one element in that particular instance.

I don't like the idea: Different behaviour with or without schema. I write code without schema first. If I decide to add a schema later code has to be rewritten. Not good.


Again, my opinion is that arbitrary XML documents are best parsed using DOM and well-defined ones are best parsed using SimpleXML.

I agree but I think I'll have something like
<config>
<option>1</option>
<option>2</option>
...
</config>
with 0 - many options quite often and iterating should be a simple foreach IMHO.


AFAIK, it's actually also impossible to find out the name of the document element using SimpleXML, even using XPath.

Yup, right now the only way is probably to wrap it in a dummy tag before giving it to SimpleXML. Sounds like a good idea anyway to me, if I have a domain specific document with varying content I'd probably do
<domain>...</domain> anyway.


I would actually expect abcd but only once:
Node Value: abcd

Concatenating all text parts _and_ returning them once for each part definitely seems wrong.

Aren't those two lines contradictory? :)

Why? Right now it returns abcd twice which is definitely wrong. Returning ab and cd or (preferably IMHO) abcd once seems right.


- Chris

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



Reply via email to