@@ 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. |
@@ 866-890 (lines=25) @@ | ||
863 | * |
|
864 | * @return string |
|
865 | */ |
|
866 | public function xml( |
|
867 | bool $multiDecodeNewHtmlEntity = false, |
|
868 | bool $htmlToXml = true, |
|
869 | bool $removeXmlHeader = true, |
|
870 | int $options = \LIBXML_NOEMPTYTAG |
|
871 | ): string { |
|
872 | $xml = $this->document->saveXML(null, $options); |
|
873 | if ($xml === false) { |
|
874 | return ''; |
|
875 | } |
|
876 | ||
877 | if ($removeXmlHeader) { |
|
878 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
879 | } |
|
880 | ||
881 | if ($htmlToXml) { |
|
882 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
883 | } else { |
|
884 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
885 | ||
886 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
887 | } |
|
888 | ||
889 | return $return; |
|
890 | } |
|
891 | ||
892 | /** |
|
893 | * @param string $selector |