On Thu, 8 Jan 2004, Andi Gutmans wrote:
> At 06:59 PM 1/7/2004 -0500, Adam Maccabee Trachtenberg wrote: > > > So i'd say let us add a method for returning the complete content. Adam > > > could you do that? > > > >That wouldn't be too difficult (although I am busy for the next day or > >two). However, as much as I loathe toggles, I'm wondering if it > >wouldn't be better to make this an object-wide setting. My thought are > >that on an object-by-object basis, you either always want tags or > >never want them.
[snip]
> I'd keep things the way they are today.
I've spent a little time looking at the code and I realize I misunderstood what was going on. Right now, given this XML:
<foo> A<b>B</b>C </foo>
Doing a "print $xml;" prints "AC". I think we should be printing "ABC". Doesn't this make more sense? I don't mind eliminating the tags, but we also kill the text node children and that doesn't seem what I'd expect.
Actually I think AC makes more sense. the B is in $xml->foo->b
The second issue is how do we allow people to get the string with tags, or "A<b>B</b>C"? (This is what I thought we were talking about.) For that, I think the best method is to modify to_xml_string() and to_xml_file().
Right now, we serialize the entire document regardless where in the document these methods are called. Instead, I say these methods should just serialize from the current location on down. So, this:
print $xml->b->to_xml_string();
Prints this:
<b>B</b>
I've whipped up a patch that does this: http://www.trachtenberg.com/patches/simplexml_toxmlstring_patch.txt
Comments?
I think that might be a nice patch because it encapsulates this service in a method. What do the rest think?
Andi
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php