Skip to content
Thomas Weinert edited this page Jul 31, 2014 · 1 revision

FluentDOM\Query::xml()

FluentDOM\Query|string xml([ string $xml = NULL ]);

Get xml contents of the first matched element or set the xml contents of all selected element nodes.

Usage

$html = <<<HTML
<html>
  <head>
    <title>Examples: FluentDOM\Query::xml()</title>
  </head>
  <body>
    <p>Hello</p>
    <p>cruel</p>
    <p>World</p>
  </body>
</html>
HTML;

echo FluentDOM($html)
  ->find('//p[position() = last()]')
  ->xml('<b>New</b>World');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::xml()</title>
  </head>
  <body>
    <p>Hello</p>
    <p>cruel</p>
    <p><b>New</b>World</p>
  </body>
</html>
Clone this wiki locally