Skip to content

No way to get the contents of a processing instruction in SimpleXML #12167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nielsdos opened this issue Sep 9, 2023 · 0 comments
Closed

No way to get the contents of a processing instruction in SimpleXML #12167

nielsdos opened this issue Sep 9, 2023 · 0 comments

Comments

@nielsdos
Copy link
Member

nielsdos commented Sep 9, 2023

Description

The following code:

<?php

$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<foo>
  <bar><?foo hello ?></bar>
</foo>
XML;

$sxe = simplexml_load_string($xml);

var_dump($sxe->xpath("//processing-instruction()")[0]->getName());
var_dump((string) $sxe->xpath("//processing-instruction()")[0]);

Resulted in this output:

string(3) "bar"
string(0) ""

But I expected this output instead:

string(3) "bar"
string(3) "hello"

PHP Version

8.1+

Operating System

Linux

nielsdos added a commit to nielsdos/php-src that referenced this issue Sep 23, 2023
nielsdos added a commit that referenced this issue Sep 25, 2023
* PHP-8.1:
  Fix GH-12167 and GH-12169: Unable to get comment or processing instruction contents in SimpleXML
nielsdos added a commit that referenced this issue Sep 25, 2023
* PHP-8.2:
  Fix GH-12167 and GH-12169: Unable to get comment or processing instruction contents in SimpleXML
nielsdos added a commit that referenced this issue Sep 25, 2023
* PHP-8.3:
  Fix GH-12167 and GH-12169: Unable to get comment or processing instruction contents in SimpleXML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant