| @@ 352-376 (lines=25) @@ | ||
| 349 | * |
|
| 350 | * @return string |
|
| 351 | */ |
|
| 352 | public function xml( |
|
| 353 | bool $multiDecodeNewHtmlEntity = false, |
|
| 354 | bool $htmlToXml = true, |
|
| 355 | bool $removeXmlHeader = true, |
|
| 356 | int $options = \LIBXML_NOEMPTYTAG |
|
| 357 | ): string { |
|
| 358 | $xml = $this->document->saveXML(null, $options); |
|
| 359 | if ($xml === false) { |
|
| 360 | return ''; |
|
| 361 | } |
|
| 362 | ||
| 363 | if ($removeXmlHeader) { |
|
| 364 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
| 365 | } |
|
| 366 | ||
| 367 | if ($htmlToXml) { |
|
| 368 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
| 369 | } else { |
|
| 370 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
| 371 | ||
| 372 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
| 373 | } |
|
| 374 | ||
| 375 | return $return; |
|
| 376 | } |
|
| 377 | ||
| 378 | /** |
|
| 379 | * Get the encoding to use. |
|
| @@ 871-895 (lines=25) @@ | ||
| 868 | * |
|
| 869 | * @return string |
|
| 870 | */ |
|
| 871 | public function xml( |
|
| 872 | bool $multiDecodeNewHtmlEntity = false, |
|
| 873 | bool $htmlToXml = true, |
|
| 874 | bool $removeXmlHeader = true, |
|
| 875 | int $options = \LIBXML_NOEMPTYTAG |
|
| 876 | ): string { |
|
| 877 | $xml = $this->document->saveXML(null, $options); |
|
| 878 | if ($xml === false) { |
|
| 879 | return ''; |
|
| 880 | } |
|
| 881 | ||
| 882 | if ($removeXmlHeader) { |
|
| 883 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
| 884 | } |
|
| 885 | ||
| 886 | if ($htmlToXml) { |
|
| 887 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
| 888 | } else { |
|
| 889 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
| 890 | ||
| 891 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
| 892 | } |
|
| 893 | ||
| 894 | return $return; |
|
| 895 | } |
|
| 896 | ||
| 897 | /** |
|
| 898 | * @param string $selector |
|