Open In App

PHP | XMLReader readString() Function

The XMLReader::readString() function is an inbuilt function in PHP which is used to read the contents of the current node as a string. Difference between readString() and getInnerXml() is that the former doesn’t includes the markup but only the content for subnodes.

Syntax:



string XMLReader::readString( void )

Parameters: This function doesn’t accept any parameter.

Return Value: This function returns the content of the current node as a string or empty string on failure.



Below examples illustrate the XMLReader::readString() function in PHP:

Example 1: In this program, we will read the value of an element without sub-nodes.

Example : In this program, we will read the value of an element with sub-nodes.

Reference: https://www.php.net/manual/en/xmlreader.readstring.php


Article Tags :