ID:               32307
 User updated by:  mike at cocoweb dot co dot uk
 Reported By:      mike at cocoweb dot co dot uk
 Status:           Bogus
 Bug Type:         SimpleXML related
 Operating System: Win XP
 PHP Version:      5.0.3
 New Comment:

Thanks for the reply.  If it is valid XML then fair enough.

However I think asXML() function should be changed to be more useful.

I initially was running the code on something along the lines of:

"<textarea ...></textarea>" and asXML() was returning "<textarea .../>"
which is not valid XHTML even though it's valid XML.  [See the latest
XHTML specification reference at the end of this message].

I have XHTML embedded in my XML file so the asXML() function causes a
mess.

I know this has nothing to do with XML, but asXML() would be more
useful if it did not change the original XML text.  I think that
asXML() should either NOT change the text, OR have a setting which
either does or does not change the text.

e.g. asXML($xml_string, true) would output "<a />" whereas:

asXML($xml_string, false) could output "<a></a>".  It would be more
useful then.

So even though the behaviour of asXML() is valid, I think it could be
improved IMHO.

XHTML Specification Reference:

[C.3. Element Minimization and Empty Element Content

Given an empty instance of an element whose content model is not EMPTY
(for example, an empty title or paragraph) do not use the minimized
form (e.g. use <p> </p> and not <p />).]


Previous Comments:
------------------------------------------------------------------------

[2005-03-15 06:35:17] [EMAIL PROTECTED]

That's not invalid XML.  <b/> is identical to <b></b> in XML and is
perfectly valid.

------------------------------------------------------------------------

[2005-03-15 06:20:53] mike at cocoweb dot co dot uk

Description:
------------
asXML() function generates an XML string which contains invalid XML.


Reproduce code:
---------------
   // Valid XML
   $string =
   "
      <a>
         <b></b>
      </a>
   ";

   // Load the string into the simplexml framework
   $XMLObject = simplexml_load_string($string);

   // View the XML object in string representation.
   echo $XMLObject->asXML();

Expected result:
----------------
      <a>
         <b></b>
      </a>

Actual result:
--------------
      <a>
         <b/>
      </a>

<!-- 

Now the <b> tag is unclosed!  i.e. invalid XML.

I am probably doing something wrong... so please help :o)

I have checked the documentation and examples on other websites all to
no avail.  Couldn't find anything relevant using Google.

-->



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32307&edit=1

Reply via email to