@@ 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. |
@@ 854-878 (lines=25) @@ | ||
851 | * |
|
852 | * @return string |
|
853 | */ |
|
854 | public function xml( |
|
855 | bool $multiDecodeNewHtmlEntity = false, |
|
856 | bool $htmlToXml = true, |
|
857 | bool $removeXmlHeader = true, |
|
858 | int $options = \LIBXML_NOEMPTYTAG |
|
859 | ): string { |
|
860 | $xml = $this->document->saveXML(null, $options); |
|
861 | if ($xml === false) { |
|
862 | return ''; |
|
863 | } |
|
864 | ||
865 | if ($removeXmlHeader) { |
|
866 | $xml = \ltrim((string) \preg_replace('/<\?xml.*\?>/', '', $xml)); |
|
867 | } |
|
868 | ||
869 | if ($htmlToXml) { |
|
870 | $return = $this->fixHtmlOutput($xml, $multiDecodeNewHtmlEntity); |
|
871 | } else { |
|
872 | $xml = $this->decodeHtmlEntity($xml, $multiDecodeNewHtmlEntity); |
|
873 | ||
874 | $return = self::putReplacedBackToPreserveHtmlEntities($xml); |
|
875 | } |
|
876 | ||
877 | return $return; |
|
878 | } |
|
879 | ||
880 | /** |
|
881 | * @param string $selector |