Skip to content

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

Closed

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

  1. added a commit that references this issue on Sep 23, 2023
    24b2b46
  2. added 2 commits that reference this issue on Sep 25, 2023
    82a84d0
    9c37a02
  3. added 2 commits that reference this issue on Sep 25, 2023
    190a535
    2e8cdd8
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