| @@ 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. |
|
| @@ 877-901 (lines=25) @@ | ||
| 874 | * |
|
| 875 | * @return string |
|
| 876 | */ |
|
| 877 | public function xml( |
|
| 878 | bool $multiDecodeNewHtmlEntity = false, |
|
| 879 | bool $htmlToXml = true, |
|
| 880 | bool $removeXmlHeader = true, |
|
| 881 | int $options = \LIBXML_NOEMPTYTAG |
|
| 882 | ): string { |
|
| 883 | $xml = $this->document->saveXML(null, $options); |
|
| 884 | if ($xml === false) { |
|
| 885 | return ''; |
|
| 886 | } |
|
| 887 | ||
| 888 | if ($removeXmlHeader) { |
|
| 889 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
| 890 | } |
|
| 891 | ||
| 892 | if ($htmlToXml) { |
|
| 893 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
| 894 | } else { |
|
| 895 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
| 896 | ||
| 897 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
| 898 | } |
|
| 899 | ||
| 900 | return $return; |
|
| 901 | } |
|
| 902 | ||
| 903 | /** |
|
| 904 | * @param string $selector |
|