
SimpleXML: Standardize string handling
Since SimpleXMLElements can be cast to string there's always been
this question of "Should I treat the SimpleXMLElement itself as a
string?" which leads to 2 scenarios:
1. The string contents are a separate value in a toString
representation, adding a level of depth. This is confusing
because the string and the element will have the same name.
2. Both the attributes, the string contents, and any string
representations like JSON have to be on the same element,
which saves depth but can lead to even more confusion.
I decided to go with 1. To fix the confusion between the two values
I set the access path of SimpleXMLElements back to the element's
own access path and change the name of the string value instead.
Before:
Name: y
Path: (string) $x->y
Child:
Name: y
Path: (string) $x->y
After:
Name: y
Path: $x->y
Child:
Name: (string) y
Path: (string) $x->y