Creating XML from a SimpleXML Object TheasXML()method returns a well-formed XML 1.0 string based on the SimpleXML object. Its prototype follows: string simplexml_element->asXML() An example follows: <?php This example returns the original XML document, except that the newline characters have been removed and the characters have been converted to their corresponding HTML entities. Learning About a Node’s Children Often you might be interested in only a particular node’s children. Using thechildren()method, retrieving them becomes a trivial affair. Its prototype follows: object simplexml_element->children() Suppose for example that thebooks.xmldocument is modified so that each book includes a cast of characters. The Hemingway book might look like the following: <book> Using thechildren()method, you can easily retrieve the characters: <?php This example returns the following: --------------------------------------------
blog comments powered by Disqus |