Skip to content

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

Description

@ndossche

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions