Talha Nehal
Talha Nehal

Reputation: 3

How to print or display DOMXPath object to see what it contains?

I want to see what is inside a DOMXPath object. I am not referring to using query/evaluate functions of XPath. At the moment I have the following code:

$file = file_get_contents("schema.xsd");

$doc = new DOMDocument();
$doc->loadXML($file);

$xpath = new DOMXPath($doc);
$xpath->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema');

How do I display the $xpath using PHP?

Upvotes: 0

Views: 732

Answers (1)

Rystraum
Rystraum

Reputation: 2025

You can use print_r, var_dump or var_export which allows you to "view" variables in PHP.

More information in this link.

As a bonus, you can wrap it in a pre or code tag so it gets laid out decently.

<pre>
<?php print_r($xpath); ?>
</pre>

Upvotes: 1

Related Questions