| @@ 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. |
|
| @@ 842-866 (lines=25) @@ | ||
| 839 | * |
|
| 840 | * @return string |
|
| 841 | */ |
|
| 842 | public function xml( |
|
| 843 | bool $multiDecodeNewHtmlEntity = false, |
|
| 844 | bool $htmlToXml = true, |
|
| 845 | bool $removeXmlHeader = true, |
|
| 846 | int $options = \LIBXML_NOEMPTYTAG |
|
| 847 | ): string { |
|
| 848 | $xml = $this->document->saveXML(null, $options); |
|
| 849 | if ($xml === false) { |
|
| 850 | return ''; |
|
| 851 | } |
|
| 852 | ||
| 853 | if ($removeXmlHeader) { |
|
| 854 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
| 855 | } |
|
| 856 | ||
| 857 | if ($htmlToXml) { |
|
| 858 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
| 859 | } else { |
|
| 860 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
| 861 | ||
| 862 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
| 863 | } |
|
| 864 | ||
| 865 | return $return; |
|
| 866 | } |
|
| 867 | ||
| 868 | /** |
|
| 869 | * @param string $selector |
|