@@ 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. |
@@ 808-832 (lines=25) @@ | ||
805 | * |
|
806 | * @return string |
|
807 | */ |
|
808 | public function xml( |
|
809 | bool $multiDecodeNewHtmlEntity = false, |
|
810 | bool $htmlToXml = true, |
|
811 | bool $removeXmlHeader = true, |
|
812 | int $options = \LIBXML_NOEMPTYTAG |
|
813 | ): string { |
|
814 | $xml = $this->document->saveXML(null, $options); |
|
815 | if ($xml === false) { |
|
816 | return ''; |
|
817 | } |
|
818 | ||
819 | if ($removeXmlHeader) { |
|
820 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
821 | } |
|
822 | ||
823 | if ($htmlToXml) { |
|
824 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
825 | } else { |
|
826 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
827 | ||
828 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
829 | } |
|
830 | ||
831 | return $return; |
|
832 | } |
|
833 | ||
834 | /** |
|
835 | * @param string $selector |