Skip to content
Advertisement

Can’t print_r domDocument

I only see:

DOMNodeList Object ( )

is this a php bug or something?

How am I supposed to see the HTML elements from the object?

Advertisement

Answer

When you create a DOMDocument instance, you have a PHP object. The DOM classes do not implement a helpful __toString functionality.

To get HTML from a DOMDocument instance, you’ll need to use saveHTML:

JavaScript

NB that your question suggests you are actually looking at a collection of elements (a DOMNodeList) rather than an actual DOMDocument instance. Depending on your code, you’ll need to extract the code for these individually:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement