class Xml extends AbstractParser (View source)

The core parser for all XML content.

Traits

Shared code for working with DOMDocument objects.
Shared code for working with the logger.
Shared code for working with raw feed content.

Properties

protected DOMDocument $domDocument The DOMDocument object which is being used to parse the content. from DomDocumentTrait
protected LoggerInterface $logger A PSR-3 logger. from LoggerTrait
protected string $rawDocument The raw, unparsed contents of the feed's stream. from RawDocumentTrait
protected Feed $feed The object which contains the parsed results.
protected int $libxml Bitwise libxml options to use for parsing XML.
protected HandlerStackInterface $middleware The handler stack which contains registered middleware.
protected Ns $ns The XML namespace handler.

Methods

string
__toString()

Returns an opaque string representing the object.

string
readStream(StreamInterface $stream)

Reads the contents of the stream resource.

getDomDocument()

Gets the DOMDocument object which is being used to parse the content.

setLogger(LoggerInterface $logger)

Sets the PSR-3 logger.

getLogger()

Retrieves the PSR-3 logger.

string
getRawDocument()

Retrieves the raw, unparsed contents of the feed's stream.

__construct(StreamInterface $stream, LoggerInterface $logger, HandlerStackInterface $handlerStack, int $libxml, bool $handleHtmlEntitiesInXml)

Constructs a new instance of this class.

Ns
getNs()

Get the XML namespace handler.

string|null
getNamespaceAlias()

Get the preferred namespace alias.

xpath()

Gets a reference to the DOMXPath object, with the default namespace already registered.

findNextRealNode(DOMNode $node)

Some DOMNode names are #comment or #text. This method will move the pointer to the next node, then the next until it finds a real XML node.

getFeed()

Retrieves the object which represents the top-level feed.

Details

string __toString()

Returns an opaque string representing the object.

Note: Use of MD5 here is not cryptographically significant.

string readStream(StreamInterface $stream)

Reads the contents of the stream resource.

Parameters

StreamInterface $stream A PSR-7 StreamInterface which is typically returned by the getBody() method of a ResponseInterface class.

Return Value

string The raw contents of the steam resource.

DOMDocument getDomDocument()

Gets the DOMDocument object which is being used to parse the content.

Return Value

DOMDocument

LoggerTrait setLogger(LoggerInterface $logger)

Sets the PSR-3 logger.

Parameters

LoggerInterface $logger A PSR-3 compatible logger.

Return Value

LoggerTrait

LoggerInterface getLogger()

Retrieves the PSR-3 logger.

Return Value

LoggerInterface

string getRawDocument()

Retrieves the raw, unparsed contents of the feed's stream.

Return Value

string

__construct(StreamInterface $stream, LoggerInterface $logger, HandlerStackInterface $handlerStack, int $libxml, bool $handleHtmlEntitiesInXml)

Constructs a new instance of this class.

Parameters

StreamInterface $stream A PSR-7 StreamInterface which is typically returned by the getBody() method of a ResponseInterface class.
LoggerInterface $logger The PSR-3 logger.
HandlerStackInterface $handlerStack The handler stack which contains registered middleware.
int $libxml The libxml value to use for parsing XML.
bool $handleHtmlEntitiesInXml Whether or not SimplePie should pre-parse the XML as HTML to resolve the entities. A value of true means that SimplePie should inject the entity definitions. A value of false means that SimplePie should NOT inject the entity definitions. The default value is false.

Exceptions

Error
TypeError

Ns getNs()

Get the XML namespace handler.

Return Value

Ns

string|null getNamespaceAlias()

Get the preferred namespace alias.

Return Value

string|null

DOMXPath xpath()

Gets a reference to the DOMXPath object, with the default namespace already registered.

Return Value

DOMXPath

DOMNode findNextRealNode(DOMNode $node)

Some DOMNode names are #comment or #text. This method will move the pointer to the next node, then the next until it finds a real XML node.

Parameters

DOMNode $node The DOMNode element to evaluate.

Return Value

DOMNode

Feed getFeed()

Retrieves the object which represents the top-level feed.

Return Value

Feed