PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<SimpleXMLSimpleXMLElement->attributes>
Last updated: Mon, 16 Jul 2012

SimpleXMLElement->asXML

(no version information, might be only in CVS)

SimpleXMLElement->asXML --  Return a well-formed XML string based on SimpleXML element

Description

string SimpleXMLElement->asXML ( void )

The asXML method formats the parent object's data in XML version 1.0.

例子 1. Get XML

<?php
$string
= <<<XML
<a>
 <b>
  <c>text</c>
  <c>stuff</c>
 </b>
 <d>
  <c>code</c>
 </d>
</a>
XML;

$xml = simplexml_load_string($string);

echo
$xml->asXML(); // <?xml ... <a><b><c>text</c><c>stuff</c> ...

?>

asXML also works on Xpath results:

例子 2. Using asXML() on Xpath results

<?php
// Continued from example XML above.

/* Search for <a><b><c> */
$result = $xml->xpath('/a/b/c');

while(list( ,
$node) = each($result)) {
   echo
$node->asXML(); // <c>text</c> and <c>stuff</c>
}
?>




<SimpleXMLSimpleXMLElement->attributes>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST