| @@ 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. |
|
| @@ 774-798 (lines=25) @@ | ||
| 771 | * |
|
| 772 | * @return string |
|
| 773 | */ |
|
| 774 | public function xml( |
|
| 775 | bool $multiDecodeNewHtmlEntity = false, |
|
| 776 | bool $htmlToXml = true, |
|
| 777 | bool $removeXmlHeader = true, |
|
| 778 | int $options = \LIBXML_NOEMPTYTAG |
|
| 779 | ): string { |
|
| 780 | $xml = $this->document->saveXML(null, $options); |
|
| 781 | if ($xml === false) { |
|
| 782 | return ''; |
|
| 783 | } |
|
| 784 | ||
| 785 | if ($removeXmlHeader) { |
|
| 786 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
| 787 | } |
|
| 788 | ||
| 789 | if ($htmlToXml) { |
|
| 790 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
| 791 | } else { |
|
| 792 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
| 793 | ||
| 794 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
| 795 | } |
|
| 796 | ||
| 797 | return $return; |
|
| 798 | } |
|
| 799 | ||
| 800 | /** |
|
| 801 | * @param string $selector |
|