-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXml.php
More file actions
79 lines (72 loc) · 1.55 KB
/
Copy pathXml.php
File metadata and controls
79 lines (72 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* @author : Jakiboy
* @package : FloatPHP
* @subpackage : Classes Http Component
* @version : 1.5.x
* @copyright : (c) 2018 - 2025 Jihad Sinnaour <[email protected]>
* @link : https://floatphp.com
* @license : MIT
*
* This file is a part of FloatPHP Framework.
*/
declare(strict_types=1);
namespace FloatPHP\Classes\Http;
use FloatPHP\Classes\Filesystem\Stringify;
/**
* Advanced XML manipulation.
*/
final class Xml
{
/**
* Parse XML string.
*
* [NOCDATA : 16384].
* [VERSION : 20908].
*
* @access public
* @param string $xml
* @param int $args
* @return mixed
*/
public static function parse(string $xml, int $args = 16384 | 20908) : mixed
{
return @simplexml_load_string($xml, 'SimpleXMLElement', $args);
}
/**
* Parse XML file.
*
* @access public
* @param string $path
* @param int $args
* @return mixed
*/
public static function parseFile(string $path, int $args = 16384 | 20908) : mixed
{
return @simplexml_load_file($path, 'SimpleXMLElement', $args);
}
/**
* Ignore XML errors.
*
* @access public
* @param bool $handling, User errors
* @return mixed
*/
public static function ignoreErrors(bool $handling = true) : bool
{
return libxml_use_internal_errors($handling);
}
/**
* Format XML string.
*
* @access public
* @param string $xml
* @return string
*/
public static function format(string $xml) : string
{
$xml = Stringify::remove('<?xml version="1.0" encoding="utf-8" ?>', $xml);
$xml = Stringify::remove('</xml>', $xml);
return $xml;
}
}