0

I am using

gravitypdf/querypath (from composer)

I am trying to achieve this function from jQuery/JS in PHP QueryPath:

jQuery("html")[0].outerHTML;

I have tried the following:

echo (string) qp($html, $filter)->parents(":root"); // can't convert document to string

echo qp($html, $filter)->parents(":root")->html(); // returns inner HTML instead of outer HTML

edit, also tried:

echo qp($html, $filter)->parents(":root")->prop('outerHTML'); // prop doesn't exist

echo qp($html, $filter)->parents(":root")->outerHTML; // always returns empty string

// XMLSerializer JS object doesn't exist in PHP...

The issue is that the outerHTML property doesn't exist in queryPath...

please help me solve this...

2 Answers 2

0

Have you tried

$('html').prop('outerHTML')

or

$(document).outerHTML

or

new XMLSerializer().serializeToString(document)
Sign up to request clarification or add additional context in comments.

1 Comment

None of these worked :(
0

Found this function in a unit test document:

echo $doc->parents(":root")->get(0)->ownerDocument->saveXML();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.